vue項目給less傳遞參數,出現 Invalid options object. Less Loader has been initialized using an options object that does not match the API schema.


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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM