vue.js怎么在v

科技 未結(jié) 4 661

vue.js怎么在v-for中使v-bind:class跟著變量值改變,我現(xiàn)在只在頁(yè)面剛渲染時(shí)才執(zhí)行一次,但不會(huì)隨著變量值變換動(dòng)態(tài)渲染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="">價(jià)格:<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>

4條回答
提交回復(fù)