less code to the required pages " statement."/> less code to the required pages " statement.">

Home  >  Article  >  Web Front-end  >  How to use less in vuejs

How to use less in vuejs

青灯夜游
青灯夜游Original
2021-09-28 15:44:551751browse

Method: 1. Install less dependencies; 2. Modify the "webpack.config.js" file and configure the loader to load dependencies so that it supports less; 3. Add "" statement is enough.

How to use less in vuejs

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

vuejs configuration uses less

The first step: Install less dependencies,

npm install less less-loader --save

Step 2:

Modify the webpack.config.js file, configure the loader to load dependencies, let it support external less, add

{

  test: /\.less$/,

  loader: "style-loader!css-loader!less-loader",

},

to the original code and now it is basically The installation has been completed

The third step:Use less

When using it, add lang="less" in the style tag and you can write the less code inside Adding scoped to the

style tag means it is only valid in this scope

<style lang="less" scoped></style>

或者@import './index.less'; //引入全局less文件

Related recommendations: "vue.js tutorial"

The above is the detailed content of How to use less in vuejs. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn