Solve the problem of using less in Vue

Solve the problem of using less in Vue

1. Install less dependency: npm install less less-loader --save

2. Modify the webpack.base.config.js file, configure the loader to load dependencies, make it support external less, and add to the original code

// This method displays the style tag style in the console { 
    test: /\.less$/,

    loader: "style-loader!css-loader!less-loader",
 
   options: { sourceMap: true } //You can see in the console which less file the current tag style comes from} 

3. Use in the project

Add lang="less" to the style tag in the vue file to use less in the tag, or import less externally

Problems encountered:

Cause: The installed version of less-loader is too high. Solution:

1.npm uninstall less-loader 2.npm install [email protected]

Or just modify the version number in the package.json file and then npm install

This is the end of this article about the use of less in vue. For more relevant content on the use of vue less, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Solve the problem of using less/sass in Vue and encountering invalid problems during use
  • vue-cli4 uses variables in the global less file to configure operations
  • Vue uses less styles globally, and components use variables defined in the global style file
  • Detailed tutorial on installing and using less in vue cli
  • A detailed tutorial on using less in Vue
  • Example of using vue + less to implement simple skinning function
  • Detailed explanation of referencing jQuery, bootstrap and using sass and less to write CSS in vue-cli

<<:  About the IE label LI text wrapping problem

>>:  Complete steps for deploying confluence with docker

Recommend

How to start and stop SpringBoot jar program deployment shell script in Linux

Without further ado, let me give you the code. Th...

JavaScript plugin encapsulation for table switching

This article shares the encapsulation code of Jav...

Solution to 700% CPU usage of Linux process that cannot be killed

Table of contents 1. Problem Discovery 2. View de...

Vue2 cube-ui time selector detailed explanation

Table of contents Preface 1. Demand and Effect ne...

MySQL 5.7.20 installation and configuration method graphic tutorial (win10)

This article shares the installation and configur...

Linux uses dual network card bond and screwdriver interface

What is bond NIC bond is a technology that is com...

Teach you about react routing in five minutes

Table of contents What is Routing Basic use of pu...

Html Select uses the selected attribute to set the default selection

Adding the attribute selected = "selected&quo...

Detailed explanation of whereis example to find a specific program in Linux

Linux finds a specific program where is The where...

Docker pull image and tag operation pull | tag

I re-read the source code of the Fabric project a...

Installation process of CentOS8 Linux 8.0.1905 (illustration)

As of now, the latest version of CentOS is CentOS...

How to make React components full screen

introduce This article is based on React + antd t...

Sample code for CSS image animation effects (photo frame)

This article introduces the sample code of CSS pi...