vue-cli创建的项目,想使用less-loader的全局变量配置,但是配置(vue.config.js文件)项出现
error in ./src/components/BookFooter.vue?vue&type=style&index=0&id=18045bd8&lang=less&scoped=true&
Module build failed (from ./node_modules/less-loader/dist/cjs.js):
ValidationError: Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.
- options has an unknown property 'globalVars'. These properties are valid:
object { lessOptions?, prependData?, appendData?, sourceMap?, implementation? }
错误,但是这句本身已给出可以配置less的配置项,我们要在 lessOptions 属性里配置less的配置项。如下:
这样配置就可以了,less的变量引用直接使用 @变量名称 即可使用,例如:@BodyWidthVar。接下来就可以使用了