1.vue_bug
1.1Error in render: "TypeError: Cannot read property '0' of undefined"”渲染错误问题
问题
报错
问题源头
解决方案
1.模板在渲染时候,读取对象中的某个对象的属性值时,这个对象不存在,
2.说通俗点就是三层表达式a.b.c,在对象a中没有对象b,那么读取对象a.b.c中的值,自然会报错。
3.如果是两层表达式a.b则不会报错,返回的是undefined。
解决方案
1.在外层添加v-if判断条件
2.注意,不能用v-show,v-show的机制是加载后,根据条件判断是否显示
2.props默认值为对象或数组
3.vue中window.onresize不生效
https://www.cnblogs.com/wangweizhang/p/12874679.html
https://blog.csdn.net/asm35548/article/details/101797302
4.vue自带属性不用箭头函数
运行结果
5.点击同一个链接多次时报错误
点击同一个链接多次时报的错误解决方案网址
采用方案2(主要原因是因为我们现在vue-router版本高于3.0.7)
https://www.cnblogs.com/rever/p/11577322.html
http://www.10qianwan.com/articledetail/619420.html
运行结果
router/index.js
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
6.components公共组件引入其他公共组件
不用@
import myLoading from './Loading.vue'