vue.js怎么在v-for中使v-bind:class跟着变量值改变,我现在只在页面刚渲染时才执行一次,但不会随着变量值变换动态渲染class
<li v-for="item in items" v-on:click="clickOneItem(item.item_id)" v-bind:class="{active: isItemSelected(item.item_id)}"> <input type="checkbox"> <img v-bind:src="item.img_url"> <div class="fyh-textcon"> <p>{{ item.title }}</p> <p class="">价格:<span>¥ {{ item.price }}</span></p> </div> </li> <script> ... methods: { isItemSelected: function (item_id) { var self = this; if (undefined == self.fetchedItems[item_id]) { return false; } return self.fetchedItems[item_id].isSeclected; } } ... </script>
http://cn.vuejs.org/guide/ins...
一周热门 更多>