No response was triggered when the state value was modified using filter() #2375
Unanswered
hmpfeng
asked this question in
Help and Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello.
I looked at the usage of filter() in Vue.js website, where an example is:
//
items是一个数组的 ref
items.value = items.value.filter((item) => item.message.match(/Foo/))
Then i define a function under actions:
delOthersVisitedViews(view) {
return new Promise(resolve => {
this.visitedViews = this.visitedViews.filter(v => v.meta.affix || v.path === view.path)
resolve([...this.visitedViews])
})
}
In this function has
this.visitedViews = this.visitedViews.filter(v => v.meta.affix || v.path === view.path)
What I want to implement is to replace the old array with the new one through this condition, and then render with Vue's response, but the above logic does not successfully perform rendering in the page, please ask why this is.
The code I define in state is:
state: (): State => ({
visitedViews: [],
})
Beta Was this translation helpful? Give feedback.
All reactions