Home Web Front-end JS Tutorial Detailed explanation of steps for using less in vue2

Detailed explanation of steps for using less in vue2

May 03, 2018 am 10:34 AM
less sass vue2

This time I will bring you a detailed explanation of the steps for using less with vue2. What are the precautions for using less with vue2. The following is a practical case, let’s take a look.

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 Now, you just need toinstallless, less-loader

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

less is used in vue

First the vue development environment has been installed successfully

When everything is ready:

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 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, and then add lang="less" to the style tag when using it. You can write less code (adding scoped in the style tag means it is only valid in this scope)

(或者
@import './index.less'; //引入全局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

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website !

Recommended reading:

JS left list transfer to the right

Analysis of JS time-sharing function

Detailed explanation of the steps of passing array parameters to controller in js

The above is the detailed content of Detailed explanation of steps for 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)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 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.

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.

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!

How to implement customizable front-end styles with React and Sass How to implement customizable front-end styles with React and Sass Sep 26, 2023 pm 10:30 PM

How to implement customizable front-end styling with React and Sass Introduction: React is a popular JavaScript library for building user interfaces. It provides a component-based approach to developing complex front-end applications. Sass is a CSS preprocessor that makes it easier to manage and organize styles by decomposing CSS code into modules. React combined with Sass can achieve customizable front-end styles. This article will introduce how to use React and Sass together to achieve customizable styles in the project.

See all articles