在Vue中使用sass和less,并解决报错问题(this.getOptions is not a function)
使用 Less
下载依赖:npm install less less-loader
在mian.js
中添加:
import less from "less";
Vue.use(less);
使用:
<style lang="less"></style>
使用 Less 时运行报错
-
this.getOptions is not a function
-
原因:
less-loader
安装的的版本过高 -
解决:重新安装较低版本
-
npm uninstall less-loader
-
npm install less-loader@5.0.0
-
使用 sass
下载依赖
npm install node-sass sass-loader style-loader
使用
<style lang="scss" scoped>
<style>
使用 sass 时运行报错
报错:this.getOptions is not a function
- 原因:
sass-loader
安装的的版本过高 - 解决:重新安装较低版本
-
npm uninstall sass-loader
-
npm install sass-loader@10.1.1
-