控制台报错:
Error in render: “TypeError: Cannot read property ‘name’ of undefined”
Error in mounted hook: “TypeError: Cannot read property ‘getAttribute’ of undefined”
vu相关的初始化顺序,
计算属性(computed)在data的后面。
console.log(his.allData)结果为空
因为初始化的时候,allData是空数组,那么this.allData[this.currentIndex]对象就不存在,所以就没有name属性,所以就会报错undefined
解决:
1.先获取,然后再重新计算
2.先获取,再判断,最后再计算