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

How vue.js traverses map

coldplay.xixi
Release: 2020-11-30 14:20:30
Original
7921 people have browsed it

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

】.

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

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template