html:

<ul id="app">
  <li v-for=‘item in items‘ @click="toggle(item)">
    <span v-if=‘item.show‘>{{item.content}}</span>
  </li>
</ul>

js:

new Vue({
  el: ‘#app‘,
  data: function() {
    return {
      items: [{
        content: ‘1 item‘,
        show: true
      }, {
        content: ‘2 item‘,
        show: true
      }, {
        content: ‘3 item‘,
        show: true
      }]
    }
  },
  methods: {
    toggle: function(item) {
            item.show = !item.show;
    }
  }
})

Logo

前往低代码交流专区

更多推荐