//实现中文模糊搜索
let reg = new RegExp('[\u4E00-\u9FA5]+');//中文匹配正则对象
if (reg.test(this.inputValue)) {
//dishTable :接收搜索后的数据 dishList:查找的数据
this.dishTable = this.dishList.filter(array => {
if (array.name != undefined) {
//匹配输入框的内容
return array.name.indexOf(this.inputValue) >= 0
}
return false
})
}
数组扩容
//扩容数组 1 val :子数组 dishSelection: 待扩容的数组
this.dishSelection=this.dishSelection.concat(val);
//扩容数组 2
this.dishSelection.push.apply(this.dishSelection,val)
根据id删除数组
deleteSetmealDish(val){
let index = this.dataForm.setmealDishes.findIndex(obj=>{
return obj.dishId===val;
})
if (index>=0){
this.dataForm.setmealDishes.splice(index,1);
}
},