如何使用v-for正确列出项目?

时间:2019-01-08 04:07:30

标签: javascript vue.js vuetify.js v-for

有人可以帮我吗? https://codepen.io/iTaurus85/pen/aRNWdy 我无法使用v-for使PriceItems.text.content出现在v-list-tile-title中。我想要类似的东西:测试计划:完全访问权限-,-,-。基本计划:完全访问权限,支持,聊天,-。等等,根据PriceItems.text

<div id="app">
  <v-app id="inspire">
   <v-flex xs4 v-for="item in PriceItems" :key="item.title" :class="item.class" >
     <h3 class="price__block-title">{{item.title}}</h3>
     <h5 class="price__block-subtitle">{{item.subTitle}}</h5>
     <v-list dense class="price__block-list">
       <v-list-tile class="price__block-item">
         <v-list-tile-content>
           <v-list-tile-title class="text-xs-center" >
             {{item.text.content}}
           </v-list-tile-title>
         </v-list-tile-content>
       </v-list-tile>
       <v-divider></v-divider>
     </v-list>
   </v-flex>
  </v-app>
</div>

.price__block{
  display: flex;
  align-items: center;
  flex-direction: column;
  background-color: #00a1c7;
  margin: 5px;
}

.v-list.price__block-list {
  background: transparent;
}

new Vue({
  el: '#app',
  data: function() {
    return {
       PriceItems: [
      {class:'price__block price__block-testing',title:'Testing',subTitle:'1 day',
      text:[
        {content:'Full access'},
        {content:' - '},
        {content:' - '},
        {content:' - '}
        ]},
      {class:'price__block price__block-testing',title:'Basic',subTitle:'7 days', 
       text:[
        {content:'Full access'},
        {content:'Support'},
        {content:'Chat'},
        {content:'-'}
        ]},
      {class:'price__block price__block-testing',title:'Standart',subTitle:'30 days', 
       text:[
        {content:'Full access'},
        {content:'Support'},
        {content:'Chat'},
        {content:'Call'}
        ]},
      {class:'price__block price__block-testing',title:'Premium',subTitle:'120 days', 
       text:[
        {content:'Full access'},
        {content:'Support'},
        {content:'Call'},
        {content:'Chat'}
        ]},
    ]

    }
  }
})

1 个答案:

答案 0 :(得分:1)

您的子内容是array,因此您也需要迭代器,就像您为priceitems v-for="item in PriceItems"

所做的那样
 <v-list-tile-title class="text-xs-center" v-for="itemContent in item.text">
     {{itemContent.content}}
  </v-list-tile-title>

Demo