vue过滤方法它是如何工作的
vue filtering method how it works
Here's the some code i try what I did
deleteajobewith_events(event){
const data =event.store.readQuery({
query: ClientJobesList,
variables: {id:1}
});
data.client.jobes.filter(jobee=>jobee.id != 101);
console.log(data);
event.store.writeQuery({ query: ClientJobesList, data});
}
If I console log the 'data', it shows the same data without filtering
这是关于 'data' 对象的提示
{
"data": {
"client": {
"id": "1",
"client_name": "Marouane",
"jobes": [
{
"id": "101",
"title": "cbkvjk",
"order": 88,
"client_id": "1"
},
.........
]
}
}
}
Filter 创建新数组,数据必须是同一类型(101 与“101”不同)所以尝试如下:
const data= {
"client": {
"id": "1",
"client_name": "Marouane",
"jobes": [
{
"id": "101",
"title": "cbkvjk",
"order": 88,
"client_id": "1"
},
{
"id": "102",
"title": "aaa",
"order": 99,
"client_id": "2"
},
]
}
}
data.client.jobes = data.client.jobes.filter(jobee=>jobee.id !== '101');
console.log(data)
您还没有将过滤后的数据分配给之前的数据:
deleteajobewith_events(event){
const data =event.store.readQuery({
query: ClientJobesList,
variables: {id:1}
});
data.client.jobes = data.client.jobes.filter(jobee=>jobee.id != 101);
console.log(data);
event.store.writeQuery({ query: ClientJobesList,
data});
}
Here's the some code i try what I did
deleteajobewith_events(event){
const data =event.store.readQuery({
query: ClientJobesList,
variables: {id:1}
});
data.client.jobes.filter(jobee=>jobee.id != 101);
console.log(data);
event.store.writeQuery({ query: ClientJobesList, data});
}
If I console log the 'data', it shows the same data without filtering
这是关于 'data' 对象的提示
{
"data": {
"client": {
"id": "1",
"client_name": "Marouane",
"jobes": [
{
"id": "101",
"title": "cbkvjk",
"order": 88,
"client_id": "1"
},
.........
]
}
}
}
Filter 创建新数组,数据必须是同一类型(101 与“101”不同)所以尝试如下:
const data= {
"client": {
"id": "1",
"client_name": "Marouane",
"jobes": [
{
"id": "101",
"title": "cbkvjk",
"order": 88,
"client_id": "1"
},
{
"id": "102",
"title": "aaa",
"order": 99,
"client_id": "2"
},
]
}
}
data.client.jobes = data.client.jobes.filter(jobee=>jobee.id !== '101');
console.log(data)
您还没有将过滤后的数据分配给之前的数据:
deleteajobewith_events(event){
const data =event.store.readQuery({
query: ClientJobesList,
variables: {id:1}
});
data.client.jobes = data.client.jobes.filter(jobee=>jobee.id != 101);
console.log(data);
event.store.writeQuery({ query: ClientJobesList,
data});
}