Home > Web Front-end > JS Tutorial > A simple tutorial on using less in vue2

A simple tutorial on using less in vue2

亚连
Release: 2018-05-28 17:03:16
Original
2504 people have browsed it

This article mainly introduces a simple tutorial for using less in vue2. Since there is no need to manually configure webpack, using less in vue is very simple. You only need to install less and less-loadder.

First of all, let me explain that if the project is created using npm init webpack project name, there is no need to manually configure webpack

, so using less in vue is very simple, you only need to install less , less-loader will do.

Steps

npm install less less-loader --save //将less和less-loader安装到开发依赖
npm run dev
Copy after login

If the installation is successful, you can use less in the vue component

<style lang="less" scoped>
 .hello{
  a{
   color:red;
  }
 }
Copy after login

Supplement:

How to use less in vue

http://element.eleme.io/ //

elementUI is based on vue2

vue Using less

First of all, the vue development environment has been installed successfully

When everything is ready:

Step one:

Install less dependencies, npm install less less-loader --save

Second step:

Modify the webpack.config.js file and configure the loader to load dependencies so that it supports external less , add

{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader",
},
Copy after login

to the original code. Now the installation is basically completed. Then when using it, add lang="less" in the style tag and you can write the code of less (add in the style tag scoped means it is only valid in this scope)

(或者
@import &#39;./index.less&#39;; //引入全局less文件
)。
(
html中直接引入:
<link rel="stylesheet/less" type="text/css" href="文件路径/styles.less" rel="external nofollow" >
<script src="文件路径/less.js" type="text/javascript"></script>
)
Copy after login

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

Solution to 403 error when using jquery ajax post data in Django

How to use ajax post in Django framework Method

How to solve the problem of Chinese garbled characters when JQuery ajax returns json

The above is the detailed content of A simple tutorial on using less in vue2. 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