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

今天工作时碰到这个报错,排查了一下,发现是.map不能映射null,
表格数据在刚进入页面没有选择参数时接口传过来的空值
兼容一下即可
//数组可能为空,无法map,加上 || [] 兼容即可 this.tableData = (res.data.data || []).map

今天工作时碰到这个报错,排查了一下,发现是.map不能映射null,
表格数据在刚进入页面没有选择参数时接口传过来的空值
兼容一下即可
//数组可能为空,无法map,加上 || [] 兼容即可 this.tableData = (res.data.data || []).map