学习高仿饿了么APP商家模块遇到的一些错误(使用vue2.0)

error1:semi
可以参照官网ESLint中的文档,在这个项目中使用了eslint,对js的语法有严格限制。在初始化的项目文件中,js文件中的语句是没有以分号结尾,如果我们加上;分号则会不通过eslint的语法检查。
解决方法:查看官方文档,在.eslintrc.js文件中添加semi: ['error', 'always']。
注意是添加在rules对象下。semi是属于语法规则,所以放置在rules下。
 
error2:Module not found: Error: Can't resolve 'stylus-loader'
 
在相关组件中,使用stylus语法,但是没能识别出来,待解决
有个治标不治本的方法是把stylus语法声明删除了,但是在程序中需要使用到stylus,还需要找找其他方法。
4月29日:
安装相关的依赖
在package.json中添加:"stylus-loader": "^2.5.1"
然后npm install
接着可能报错的,
运行 npm install stylus-loader css-loader style-loader --save-dev 
然后 npm install stylus --save-dev
stylus-loader 是webpack用来加载stylus文件的加载器,他的核心功能还是调用stylus的api
 
error3 : * ./lib/html5-entities.js in ./~/html-entities/index.js
 
原因居然是杀毒软件把电脑中的一个文件删除了,导致不能运行npm run dev
使用了webstorm中的历史记录发现这个文件在某个时刻被删除了,所以使用了版本回退。webstorm还是挺不错的。
 
error4: You have to install axios
Uncaught (in promise) TypeError: Cannot read property 'protocol' of undefined
图中第二红色错误提示解决方法:在main.js中不要使用Vue.use(axios);而是在需要的vue文件中重新import一次。
 
error5: TypeError: _this._initialScroll is not a function
方法调用来自于methods中,应该检查一下methods中的function,在methods中不应该使用ES6的箭头函数
 
error6:
[Vue warn]: Property or method "$index" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
在vue2版本中$index和$key已经被移除
官方:已经移除了 $index 和 $key 这两个隐式声明变量,以便在 v-for 中显式定义。这可以使没有太多 Vue 开发经验的开发者更好地阅读代码,并且在处理嵌套循环时也能产生更清晰的行为。
在学习视频过程中容易受到旧版本影响,当遇到不可思议的bug时,一定要回到官网中阅读相关知识点.
 
error7:
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "selectType"
 
这个错误是因为直接复制给了组件的selectType属性,
修改:
直接赋值改为emit
1.v-model 默认是双向绑定,开始时使用默认 属性uName 双向绑定,意味着存在,组件内部 修改uName,从而影响外部 组件的风险。
2.改正后,在组件内部再构建一套属性域,从而与外界解耦
 
 
 
 
 
 
 
原文地址:https://www.cnblogs.com/synchronize/p/7105331.html