700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)

vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)

时间:2020-03-21 05:23:37

相关推荐

vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)

在查看信息时,界面没反应,然后查看控制台报错

index.vue?t=1680763420735:497 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'comcode')

然后查找获取数据的方法

getInfo(row.id).then((response) => {info.value = response.data ;});

f12查看返回数据信息如下:

{msg: "操作成功", code: 200}

因为没有正确返回数据,导致获取response.data时是一个undefined ,因此展示数据的时候就会出错

{{ code}}

所以修改获取数据的function,然后将获取的数据判断一下,如果为undefined,则赋值一个新对象,否则从data中获取数据

getInfo(row.id).then((response) => {info.value = response.data === undefined ? {} : response.data;});

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。