?在查看信息時,界面沒反應,然后查看控制臺報錯
index.vue?t=1680763420735:497 Uncaught (in promise) TypeError:
Cannot read properties of undefined (reading 'comcode')
然后查找獲取數(shù)據(jù)的方法
getInfo(row.id).then((response) => {
info.value = response.data ;
});
?f12查看返回數(shù)據(jù)信息如下:
{msg: "操作成功", code: 200}
因為沒有正確返回數(shù)據(jù),導致獲取response.data時是一個undefined ,因此展示數(shù)據(jù)的時候就會出錯文章來源:http://www.zghlxwxcb.cn/news/detail-621328.html
{{ info.comcode}}
所以修改獲取數(shù)據(jù)的function,然后將獲取的數(shù)據(jù)判斷一下,如果為undefined,則賦值一個新對象,否則從data中獲取數(shù)據(jù)文章來源地址http://www.zghlxwxcb.cn/news/detail-621328.html
getInfo(row.id).then((response) => {
info.value = response.data === undefined ? {} : response.data;
});
到了這里,關于vue Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘comcode‘)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!