Home > Web Front-end > Front-end Q&A > How to use less in vuejs

How to use less in vuejs

青灯夜游
Release: 2023-01-11 09:22:43
Original
1823 people have browsed it

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
Copy after login

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",

},
Copy after login

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文件
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template