vue 开发 遇到的问题
文章目录
最近接手了一个vue 的项目 , 在这里记录一下遇到的问题
1.vscode编辑器 没有 import 提示的解决办法
在项目根目录新建 `jsconfig.json` 添加如下配置项
{
"include": [ "./src/\*\*/\*"]
}
2.引入项目公有工具类时 项目构建报错
"export 'default' (imported as 'Log') was not found in '../../../utils/utils'
追踪 utils.js 发现当前的导出方式为 export 并不是 export default
因为export了多个工具在当前文件 所以import 应该为集合的方式
import { Log } from'../../../utils/utils';
3.在新建组件时报错
Expression expected.
原因是在 vue文件中data里面 renturn后习惯性写了个 , 改为 ; 即可

3.eslint报错
TypeError: Right-hand side of 'instanceof' is not callable
原因是props 内的type定义错误导致报错
data: {
type:JSON,
default: {},
}
改为:
data: {
type:Object,
default:() => {},
}
4.eslint报错
terators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.
原因是 eslint 不推荐for in/ for of 循环应该forEach
5.eslint报错
Assignment to property of function parameter 'value'
原因是eslint不推荐直接操作函数的参数 新建一个变量即可

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论