Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

@click="active=index" 这行是什么意思,绑定事件不应该是一个方法吗?

<div id="app">

<div class="container">
  <ul class="title flex">
    <li
      v-for="(item,index) in titles"
      @click="active=index"  
      :class="{active:index===active}"
    >
      {{item}}
    </li>
  </ul>
  <ul>
    <li v-show="active===0">11</li>
    <li v-show="active===1">22</li>
    <li v-show="active===2">33</li>
  </ul>
</div>

</div>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

@clickv-on:click的缩写,指令绑定是表达式,不一定非得是方法哦
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...