]."/> ].">

Home  >  Article  >  Web Front-end  >  How vue.js traverses map

How vue.js traverses map

coldplay.xixi
coldplay.xixiOriginal
2020-11-10 15:42:507827browse

Vue.js method of traversing map: vue uses [v-for] to traverse Map, the code is [6fab9fed0ee924d0559946d206b7b31f】.

How vue.js traverses map

The operating environment of this tutorial: windows10 system, vue2.9, this article is applicable to all brands of computers.

【Recommended related articles: vue.js

vue.js method of traversing map:

The object data is as follows:

"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": "沧州"
}]

The traversal method is as follows:

<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>

The key is v-for="(item, key) of cities", which is equivalent to the Map structure(key, value)

Related free learning recommendations: JavaScript(Video)

The above is the detailed content of How vue.js traverses map. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn