[Vue warn]: Error in callback for watcher “xxx“: “TypeError: Cannot read property ‘0‘ of undefined“
报错:相关代码watch: {detailInfo() {this.imagesLength = this.detailInfo.detailImages[0].list.length;},}分析:watch中detailInfo无数据传入解决:添加个判断条件,无errorwatch: {detailInfo() {// this.imagesLength = this.detailInfo.de
·
报错:
相关代码
watch: {
detailInfo() {
this.imagesLength = this.detailInfo.detailImages[0].list.length;
},
}
分析:watch中detailInfo无数据传入
解决:添加个判断条件,无error
watch: {
detailInfo() {
// this.imagesLength = this.detailInfo.detailImages[0].list.length;
this.imagesLength =
this.detailInfo.length > 0
? this.detailInfo.detailImages[0].list.length
: 0;
},
},
更多推荐
已为社区贡献1条内容
所有评论(0)