控制臺報錯 TypeError: Cannot read properties of undefined (reading 'map')

我的錯誤原因:第一次頁面渲染的時候,map的對象是undefined或null,文章來源:http://www.zghlxwxcb.cn/news/detail-725153.html
解決方法:在前面加個要進行判斷,當有值時再去遍歷文章來源地址http://www.zghlxwxcb.cn/news/detail-725153.html
// 1、可選鏈式操作符 ?.
this.array?.map(()=>{ …… })
// 2、&& 判斷
this.array&&this.array.map(()=>{ …… })
到了這里,關于TypeError: Cannot read properties of undefined (reading ‘map‘)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!