vue里多维数组的索引值怎么获得 财富值86

2016-10-27 11:09发布

[

            {                 "_id": "578c2f687ec482840b07e4e8",                 "nodes": [                     "XYK0101000002G",                     "XYK0101000007G"                 ],                 "users": [                     {                         "_id": "578c2f2c7ec482840b07e4e7",                         "name": "18951904112",                         "group_id": "578c2f687ec482840b07e4e8",                         "latest_get_message_time": 1477385019,                         "role": "master",                         "info": {                             "phone": "1895112",                             "name": "",                             "address": "江苏",                             "mou_num": 0,                             "pond_num": 0,                             "per_mou_fish": 0,                             "kinds": [                                 "混养"                             ]                         }                     },                     {                         "_id": "57e3531f79dc5d5417b55825",                         "name": "17895001036",                         "group_id": "578c2f687ec482840b07e4e8",                         "role": "helper",                         "info": {                             "phone": "1904112",                             "name": "李",                             "address": "江苏省园区",                             "mou_num": 0,                             "pond_num": 0,                             "per_mou_fish": 0,                             "kinds": [                                 "混养"                             ]                         }                     }                 ]             },             {                 "_id": "578c2f687ec482840b07e4e8",                 "nodes": [                     "XYK0101000002G",                     "XYK0101000007G"                 ],                 "users": [                     {                         "_id": "578c2f2c7ec482840b07e4e7",                         "name": "18951112",                         "group_id": "578c2f687ec482840b07e4e8",                         "latest_get_message_time": 1477385019,                         "role": "master",                         "info": {                             "phone": "18951904112",                             "name": "",                             "address": "",                             "mou_num": 0,                             "pond_num": 0,                             "per_mou_fish": 0,                             "kinds": [                                 "混养"                             ]                         }                     }                 ]             }         ];                  这是数据                  

一个users是一个数据,我想按users的记录数作为序号,怎么实现

付费偷看设置
发送
6条回答
青言 - 这个人很懒,什么都没留下
1楼 · 2016-10-27 11:22.采纳回答

参考资料:Vue.js v2.0 中文教程

但是这个地方题主是不是想根据users的数量进行编号,不知道我理解的对不对,这样子我的建议是在最外层init一个变量,最里层的v-for每次++。

1.x (userIndex , userInfo) in list.users 索引在前

显示声明index:
v-for="(userInfo , userIndex) in list.users"

2.x (userInfo , userIndex) in list.users 值在前,并且$index已废弃

另外也可以为数组索引指定别名(如果值是对象可以为键指定别名):
这个可以解决父子之间的索引问题,不至于混乱,当然是题外话。

一周热门 更多>