Home> Web Front-end> Vue.js> body text

How can vue.js use less

coldplay.xixi
Release: 2020-11-30 16:56:06
Original
1781 people have browsed it

vue.js can use less methods: 1. In less, we are allowed to define it in the form of variables. The definition method [@k:v;] and the usage method [@k]; 2. String Splice variables.

How can vue.js use less

The operating environment of this tutorial: windows10 system, vue2.5.2, this article is applicable to all brands of computers.

[Related article recommendations:vue.js]

vue.js can use less methods:

Dependency download

1. First use npm to download the dependencies;

npm install --save less less-loader
Copy after login

2. After the installation is completed, check whether the installation is successful;

lessc -v
Copy after login

3. If After the installation is successful, the version after successful installation will be displayed;

How can vue.js use less

Reference method

1. In main.js

import less from 'less' Vue.use(less)
Copy after login

2. Then create a .vue file and let’s start playing;

Note: The independent vue file needs to introduce less

Get started

1. The use of variables in less;

In less, we are allowed to use variables to define, Definition method: @k:v; Usage method: @k;

Copy after login

At this time, a square with a width of 100px, a height of 100px and a red background will be displayed on the page;

How can vue.js use less

2. How to use string splicing variables;

Copy after login

Note: the path needs to be wrapped with "", @{img} will only take effect if the variable is introduced;

How can vue.js use less

3. Multi-layer nested variable calculation;

Copy after login

As you can see, less can be nested, allowing us to see the css structure clearly at once; in addition to nesting After using it, have you found that its calculation is really powerful?

How can vue.js use less

4. Mixed = Function

我是box1
我是box2
Copy after login

How can vue.js use less

##Related free learning recommendations:

JavaScript(video)

The above is the detailed content of How can vue.js use less. 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!