vue3中全局引入less

1、安装less less-loader

javascript 复制代码
yarn add less less-loader

2、安装style-resources-loader

javascript 复制代码
yarn add style-resources-loader

3、安装vue-cli-plugin-style-resources-loader

javascript 复制代码
yarn add vue-cli-plugin-style-resources-loader

4、配置vue.config.js

如果没有则新建vue.config.js

javascript 复制代码
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/base.less')
            ]
        }
    }
})

4.1 base.less

css 复制代码
@textColor: #99999;
@bgColor: #f2f3f4;
@lineHeight: 30px;
.textValue:{
    color: @textColor;
    line-height: @lineHeight;
}
相关推荐
云水一下5 小时前
从零开始!VMware安装Fedora Workstation 44桌面系统完整教程
前端
小码哥_常6 小时前
安卓黑科技:实现多平台商品详情页一键跳转APP
前端
killerbasd6 小时前
还是迷茫 5.3
前端·react.js·前端框架
不会敲代码17 小时前
TCP/IP 与前端性能:从数据包到首次渲染的底层逻辑
前端·tcp/ip
kyriewen7 小时前
奥特曼借GPT-5.5干杯,而你的Copilot正按Token收钱
前端·github·openai
AC赳赳老秦7 小时前
投标合规提效:用 OpenClaw 实现标书 / 合同自动审核、关键词校验、格式优化,降低废标风险
开发语言·前端·python·eclipse·emacs·deepseek·openclaw
kyriewen7 小时前
代码写成一锅粥?3个设计模式让你的项目“起死回生”
前端·javascript·设计模式
千寻girling8 小时前
《 Git 详细教程 》
前端·后端·面试
之歆9 小时前
DAY08_CSS浮动与行内块布局实战指南(下)
前端·css
yqcoder9 小时前
CSS Position 全解析:5 种定位模式详解
前端·css