在 v-for 循环中从列表更新属性

问题描述 投票:0回答:0

当你使用单个组件时,更新它的属性很容易,因为你有特定于该组件的数据或道具。但是组件列表怎么样? 在获取成功返回后,我必须从帖子中更新喜欢的数量,但是当获取返回时我无法访问循环外的属性。

循环中的组件(有效):

<div v-for="posts in post">
    <Post 
        likes: {{ post.likes }}
        <a :href="'update/'+post._id">Update</a>    
    </Post>
</div> 

<script>
...
data() {
    return {
        posts: [],
        ...
    }
}
...
</script>

vue.js loops attributes updates v-for
© www.soinside.com 2019 - 2024. All rights reserved.