运行Vue项目出现: TypeError: this.getOptions is not a function
在编写样式后运行出现错误:
<style lang="less" scoped>
.box {
width: 500px;
height: 300px;
margin: 0 auto;
padding: 10px 10px;
border-radius: 5px;
border: 1px solid #333;
text-align: center;
}
</style>
无法使用 less scoped 加上之后运行就会报错误 TypeError: this.getOptions is not a function
在查证之后的得知原因:less-loader安装的版本过高 不适用
解决方案:
1.npm uninstall less-loader 或者 cnpm uninstall less-loader
2.cnpm install less-loader@5.0.0 或者更低的版本
3.删除node_modules 在终端中使用命令:npm install 自动下载适用于本版本的所有依赖
之后运行就不会报错了