使用Vue.js实现列表选中效果(转载)
Demo
new Vue({ el: "#app", data: { gameNames: [‘魔兽世界‘, ‘暗黑破坏神Ⅲ‘, ‘星际争霸Ⅱ‘, ‘炉石传说‘, ‘风暴英雄‘, ‘守望先锋‘ ], activeName: ‘‘ }, methods: { selected: function(gameName) { this.activeName = gameName } } })
<div id="app"> <p class="city"> 切换城市: <a href="#" v-on:click="changeCity(item)" v-for="item in choices" :class="{active: activeCity == item}"> {{item.cities}} </a> </p> </div>
时间: 2024-10-11 17:26:56