【发布时间】:2019-12-08 09:58:55
【问题描述】:
我想在用户点击项目时更新所选项目的样式。 nextIndex/event.index 已更新,但样式不适用。感谢您的帮助。
https://play.nativescript.org/?template=play-vue&id=ihH3iO
export default {
name: "CustomListView",
props: ["page", "title", "items", "selectedIndex"],
data() {
return {
nextIndex: this.selectedIndex ? this.selectedIndex : undefined
};
},
methods: {
onItemTap(event) {
this.nextIndex = event.index;
}
}
};
.selected {
color: white;
background-color: black;
}
<ListView for="(item, index) in items" @itemTap="onItemTap">
<v-template>
<Label :class="['list-item-label', { selected: index == nextIndex }]" :text="item" />
</v-template>
</ListView>
【问题讨论】:
-
你可以创建一个游乐场吗?
-
@Narendra 我用游乐场网址更新了问题,谢谢!
标签: nativescript nativescript-vue