1、 微信小程序报这类错误:
(in promise) MiniProgramError Cannot read property ‘findIndex’ of null TypeError: Cannot read property ‘findIndex’ of null
data: {
addval:"",
editval:"",
typeList:[]
},
// 添加
async add(){
let typeName =
// 判断分类名称是否重复
// ();
const index = (item => {
return == typeName
})
问题所在:
发现当typeList中的值为空时,就会报这个错误,有 数据时就不会报错
解决办法:
在循环之前加一个判断
**= || [ ]**
// 判断分类名称是否重复
var index = (item => {
return == typeName
})