运行起来
i=1,index=0
-----------
i=2,index=1
运行起来
i=1,index=0
-----------
i=2,index=1
|
1
懵在哪?
|
|
hoyixiAug 28, 2019
3
v-for="(i,index) in ['a','b','c']"
|
|
4
v-for
预期:Array | Object | number | string | Iterable (2.6 新增) vue 官网。 |
|
5
@yangshan010 收到,感谢人形 apidoc
|
|
marcong95Aug 28, 2019
7
v-for 遍历 number 的话是从 1 开始的
|
|
BiwoodAug 28, 2019
8
|
|
9
这个实现在这里: https://github.com/vuejs/vue/blob/6fe07ebf5ab3fea1860c59fe7cdd2ec1b760f9b0/src/core/instance/render-helpers/render-list.js
具体实现内容如下: ``` if (typeof val === 'number') { ret = new Array(val) for (i = 0; i < val; i++) { ret[i] = render(i + 1, i) } } ``` |