1. vue add style-resources-loader
2.
const path = require("path");//这一段需要自行添加 module.exports = { pluginOptions: { 'style-resources-loader': { preProcessor: 'less', patterns: [ path.resolve(__dirname, "src/style/global.less")//需要自行添加 ] } } }
3.
<style lang="less" scoped> @import '~@/assets/styles/varibles.less'; //全局变量存放的文件(要加~) </style>