小编Mic*_*ael的帖子

v-for,如何打开点击的列表项

我在使用 Vue 时遇到了问题,我花了很多时间,在发布之前尝试在 google/stackoverflow 中找到答案,可能我不知道如何用文字解释我的问题。

这是代码:

  <div class="list-group" v-if="showPlaces == false">
    <a href="#" @click="showPlaces = true" :key="place.id" v-for="place in places" class="list-group-item list-group-item-action">{{place.number}}</a>
  </div>

  <div v-else>
    <button @click="showPlaces = false" class="btn btn-primary">Go back</button>
    {{this.places.number}}asd
  </div>


  data() {
    return {
      showPlaces: false,
      places: [
        {number: 'First Place'},
        {number: 'Second Place'},
        {number: 'Third Place'},
        {number: 'Fourth Place'},
        {number: 'Fifth Place'},
        {number: 'Sixth Place'},
        {number: 'Seventh Place'},
        {number: 'Eighth Place'},
        {number: 'Ninth Place'},
        {number: 'Tenth Place'},
      ]
    }
  }
Run Code Online (Sandbox Code Playgroud)

我已经添加了当前应用程序的图片以及我想要实现的目标。

提前致谢! 带有应用程序和一些注释的图像

vue.js vue-component vuejs2

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

vue-component ×1

vue.js ×1

vuejs2 ×1