vue.js遍历map的方法:
对象数据如下:
"cities": { "A": [{ "id": 56, "spell": "aba", "name": "阿坝" }, { "id": 57, "spell": "akesu", "name": "阿克苏" }], "B": [{ "id": 58, "spell": "bAIyin", "name": "白银" }, { "id": 59, "spell": "bangbu", "name": "蚌埠" }], "C": [{ "id": 60, "spell": "chengdu", "name": "成都" }, { "id": 61, "spell": "cangzhou", "name": "沧州" }]
遍历方法如下:
<div class="area" v-for="(item, key) of cities" :key="key"> <div class="title border-topbottom">{{key}}</div> <div class="item-list"> <div class="item border-bottom" v-for="innerItem of item" :key="innerItem.id">{{innerItem.name}}</div> </div> </div>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)