问题描述
根据 checkmove.id 去匹配下面的id,匹配到了就把checkmove取代id所在的对象,但不知道怎么写
that.functionsList
[
{
listRight: [
{
id: getID(),
tasks: [
{
id: getID(),
tasks: '0-0'
},
{
id: getID(),
tasks: '0-1'
},
]
},
{
id: getID(),
tasks: [
{
id: getID(),
tasks: '1-0'
},
{
id: getID(),
tasks: '1-1'
},
]
},
],
name:''
},
{
listRight: [
{
id: getID(),
tasks: [
{
id: getID(),
tasks: '0-0'
},
{
id: getID(),
tasks: '0-1'
},
]
},
{
id: getID(),
tasks: [
{
id: getID(),
tasks: '1-0'
},
{
id: getID(),
tasks: '1-1'
},
]
},
],
name:''
},
]
相关代码
Bus.$on('changeCheckItem',checkmove => {
console.log('this.functionsList: ', this.functionsList);
this.functionsList.some((item1,index1) => {
if (item1.name === this.funcName) {
let listRight = this.functionsList[index1].listRight;
function func(list) {
list.map(item2 => {
if (item2.id === checkmove.id) {
// item = value
}
if (item2.hasOwnProperty('tasks')&&item2.tasks.length > 0) {
func(item2.tasks)
}
})
}
func(listRight)
return true;
}
})
})
这里tasks依然跟上次一样考虑了嵌套多层的情况。