“写操作失败:计算属性”帖子”被读取”
我尝试从PostList中删除帖子,但是获得错误
<PostList
:posts="sortedAndSearchedPosts"
@remove="removePost"
v-if="!isPostsLoading"
/>
删除邮政功能
removePost(post) {
this.posts = this.posts.filter((p) => p.id !== post.id);
},
帖子在此处初始化
computed: {
...mapState({
posts: (state) => state.post.posts,
}),
...mapGetters({
sortedPosts: "post/sortedPosts",
sortedAndSearchedPosts: "post/sortedAndSearchedPosts",
}),
},
I try remove post from PostList, but getting an error
<PostList
:posts="sortedAndSearchedPosts"
@remove="removePost"
v-if="!isPostsLoading"
/>
remove post function
removePost(post) {
this.posts = this.posts.filter((p) => p.id !== post.id);
},
posts initialized here
computed: {
...mapState({
posts: (state) => state.post.posts,
}),
...mapGetters({
sortedPosts: "post/sortedPosts",
sortedAndSearchedPosts: "post/sortedAndSearchedPosts",
}),
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,尚不清楚
this.posts
实际上是在哪里设置的。如果我猜对您的体系结构正确,我会看到2个选项:
sortedandSearchedPosts
帖子
:并更新代码以使用本地帖子列表:
希望这会有所帮助!
Not clear where
this.posts
are actually initially set up.If I guess your architecture right, I see 2 options for you:
sortedAndSearchedPosts
reflects the change directlyposts
:and update your code to use the local list of posts:
Hope this helps!