xzybk


<div id="app"> <ul> <li v-for="(todo, index) in todos" v-on:click="addClass(index)" v-bind:class="{ blue:index==current}">{{ todo.text }}</li> </ul> </div> <script> new Vue({ el: \'#app\', data: { current:0, todos: [ { text: \'选项一\' }, { text: \'选项二\' }, { text: \'选项三\' } ] }, methods:{ addClass:function(index){ this.current=index; } } })

分类:

技术点:

相关文章:

  • 2021-11-29
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-29
  • 2021-11-29
  • 2021-11-29
  • 2021-11-29
  • 2021-12-06
  • 2022-12-23
相关资源
相似解决方案