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

A simple tutorial on using less in vue2

May 28, 2018 pm 05:03 PM
less sass vue2

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between the life cycle execution order in vue2 and vue3 What is the difference between the life cycle execution order in vue2 and vue3 May 16, 2023 pm 09:40 PM

Difference in life cycle execution order between vue2 and vue3 Life cycle comparison The execution order in vue2 beforeCreate=>created=>beforeMount=>mounted=>beforeUpdate=>updated=>beforeDestroy=>destroyed The execution order in vue3 setup=>onBeforeMount=>onMounted=> onBeforeUpdate=>onUpdated=>onBeforeUnmount=&g

Quickly understand the Vue2 diff algorithm (detailed graphic explanation) Quickly understand the Vue2 diff algorithm (detailed graphic explanation) Mar 17, 2023 pm 08:23 PM

The diff algorithm is an efficient algorithm that compares tree nodes at the same level, avoiding the need to search and traverse the tree layer by layer. So how much do you know about the diff algorithm? The following article will give you an in-depth analysis of the diff algorithm of vue2. I hope it will be helpful to you!

What does sass software mean? What does sass software mean? Aug 15, 2022 am 11:39 AM

The full name of SASS is "Software as a service", which means "software as a service"; it is a software deployment model in which third-party suppliers build applications on cloud infrastructure and provide these to customers through the Internet in the form of subscriptions. applications that do not require customers to build the underlying infrastructure upfront. This means that the software can be accessed on any device with an internet connection and a web browser, unlike traditional software that can only be installed on your local machine.

What does sass mean when vue creates a project? What does sass mean when vue creates a project? Jun 21, 2022 am 10:33 AM

The sass used by Vue when creating a project is to strengthen the css auxiliary tool and is an extension of css; sass is a css preprocessing language written in the buby language. It has the same strict indentation style as html and is consistent with css writing specifications. Curly braces and semicolons are not used.

Let's talk about how to set up the 404 interface in Vue2 and Vue3 Let's talk about how to set up the 404 interface in Vue2 and Vue3 Feb 17, 2023 pm 02:25 PM

This article will take you through Vue learning and talk about how to set up the 404 interface in Vue2 and Vue3. I hope it will be helpful to you!

What to do if there is an error when compiling SASS in vue project What to do if there is an error when compiling SASS in vue project Jan 05, 2023 pm 04:20 PM

Solution to the Vue project compilation sass error: 1. Use the image source "cnpm install node-sass sass-loader --save-dev" to install sass; 2. Change the "sass-loader" version in "package.json" to " "sass-loader": "^7.3.1","; 3. Use it directly in the page or use @ instead of src.

The difference between Sass and less The difference between Sass and less Oct 12, 2023 am 10:16 AM

The differences between Sass and less include syntax differences, definition methods of variables and mixers, import methods, operator support, extensibility, etc. Detailed introduction: 1. Syntax difference. Sass uses indentation to express nested rules, similar to Python syntax. Less uses CSS-like syntax and uses braces to express nested rules; 2. Variables and mixers. Definition method, in Sass, variables are defined using the `$` symbol, while mixers are defined using the `@mixin` keyword, in Less and so on.

How to use SASS styles in Angular projects How to use SASS styles in Angular projects May 09, 2022 am 10:51 AM

How to use SASS styles in Angular projects? The following article will introduce to you how to use SASS styles in Angular. I hope it will be helpful to you!

See all articles