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。接下來就可以使用了