简体   繁体   中英

V-for vue.js data

Hi am trying to show all array that i have with this example i can show only the first line because [0] i wanna show all

<div class="description" v-for="item in sitePartVoice[0].part_attributes">
<small><strong>{{item.x_name}}</strong> {{item.x_value}}</small>
</div>

i have try this

<div v-for="item in items">
 <div class="description" v-for="item in sitePartVoice.part_attributes">
    <small><strong>{{item.x_name}}</strong> {{item.x_value}}</small>
    </div>
</div>

No Success thanks

it should be like

<div v-for="siteParts in sitePartVoice">
 <div class="description" v-for="item in siteParts.part_attributes">
    <small><strong>{{item.x_name}}</strong> {{item.x_value}}</small>
    </div>
</div>

Let's say you have this kind of data:

    data: () => ({
      sitePartVoice: [
        { 
            part_attributes: [
                {
                    prop1: 'value1'
                }
            ] 
        },
        { 
            part_attributes: [
                {
                    prop1: 'value1'
                }
            ] 
        }
      ]
    })

then to loop each sitePartVoice and loop the part_attributes inside it:

        <div v-for="item in sitePartVoice">
            <div class="description" v-for="i in item.part_attributes">
                <small>{{i.prop1}}</small>
            </div>
        </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM