小白兔晒黑了

导航

 

 

 

 

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>

</head>
<body>
  <div id="app">
    <ul>
      <li v-for="(movie,index)  in movies"  @click="changeLiClass(index)" :class="{checked:index==nowIndex}" >
        {{index+movie}}
      </li>
    </ul>
  </div>
</body>
<script src="../vue.js"></script>
<script>
  const app = new Vue({
    el:"#app",
    data:{
      nowIndex:0,
      movies:['蓝猫与淘气','黑猫与白猫','进击的巨人','森林好小子']
    },
    methods:{
      changeLiClass(index){
        this.nowIndex=index
      }
    }
  })
</script>
<style type="text/css">
  .checked {color:greenyellow}
</style>
</html>

 

posted on 2021-09-15 01:08  小白兔晒黑了  阅读(374)  评论(0编辑  收藏  举报