需求:
代码实现:
<!-- css --><style>.red{color: red;}</style><!-- html --><divid="app"><ul><liv-for="item,index in movies":class="{red: changeRed == index}"v-on:click="change(index)">{{item}}</li></ul></div><!-- JavaScript --><scriptsrc="../JS/vue.js"></script><script>const app=newVue({     el:'#app',     data:{       movies:['肖申克的救赎','泰坦尼克号','当幸福来敲门','流浪地球'],       changeRed:-1},     methods:{       change:function(index){this.changeRed=index;}}})</script> 代码解释: