Uncaught (in promise) TypeError: Cannot read properties of null (reading 'map')报错

今天工作时碰到这个报错,排查了一下,发现是.map不能映射null,

表格数据在刚进入页面没有选择参数时接口传过来的空值

兼容一下即可

//数组可能为空,无法map,加上 || [] 兼容即可
          this.tableData = (res.data.data || []).map

 

posted @ 2022-01-18 12:05  故居风  阅读(5674)  评论(0)    收藏  举报