1、安装less less-loader
yarn add less less-loader
2、安装style-resources-loader
yarn add style-resources-loader
3、安装vue-cli-plugin-style-resources-loader
yarn add vue-cli-plugin-style-resources-loader
4、配置
如果没有则新建
const path = require('path')
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
pluginOptions: {
"style-resources-loader": {
preProcessor: "less",
patterns: [
path.resolve(__dirname,'./src/assets/css/')
]
}
}
})
4.1
@textColor: #99999;
@bgColor: #f2f3f4;
@lineHeight: 30px;
.textValue:{
color: @textColor;
line-height: @lineHeight;
}