Skip to content

Commit e845a86

Browse files
author
tianting
committed
list rendering translation
1 parent 1a58494 commit e845a86

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/guide/list.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ order: 8
66

77
## `v-for`
88

9-
We can use the `v-for` directive to render a list of items based on an array. The `v-for` directive requires a special syntax in the form of `item in items`, where `items` is the source data array and `item` is an **alias** for the array element being iterated on:
9+
我们用`v-for` 指令根据一组数组的选项列表进行渲染。`v-for` 指令需要以 `item in items` 形式的特殊语法,`items` 是源数据数组并且 `item` 是数组元素迭代的别名。
1010

1111
### 基本用法
1212

1313
``` html
1414
<ul id="example-1">
15-
<li v-for="item in items">
16-
{{ item.message }}
17-
</li>
15+
<li v-for="item in items">
16+
{{ item.message }}
17+
</li>
1818
</ul>
1919
```
2020

2121
``` js
2222
var example1 = new Vue({
23-
el: '#example-1',
24-
data: {
25-
items: [
26-
{ message: 'Foo' },
27-
{ message: 'Bar' }
28-
]
29-
}
23+
el: '#example-1',
24+
data: {
25+
items: [
26+
{message: 'foo' },
27+
{message: 'Bar' }
28+
]
29+
}
3030
})
3131
```
3232

33-
Result:
33+
结果:
3434

3535
{% raw %}
3636
<ul id="example-1" class="demo">
@@ -56,7 +56,7 @@ var example1 = new Vue({
5656
</script>
5757
{% endraw %}
5858

59-
Inside `v-for` blocks we have full access to parent scope properties. `v-for` also supports an optional second argument for the index of the current item.
59+
`v-for` 块内部,我们有完全访问父作用域的属性。`v-for` 也支持当前列表的索引可选的第二个参数。
6060

6161
``` html
6262
<ul id="example-2">
@@ -79,7 +79,7 @@ var example2 = new Vue({
7979
})
8080
```
8181

82-
Result:
82+
结果:
8383

8484
{% raw%}
8585
<ul id="example-2" class="demo">
@@ -106,15 +106,15 @@ var example2 = new Vue({
106106
</script>
107107
{% endraw %}
108108

109-
You can also use `of` as the delimiter instead of `in`, so that it is closer to JavaScript's syntax for iterators:
109+
你也可以用 `of` 替代 `in` 作为分隔符, 所以它是最接近JavaScript迭代器的语法
110110

111111
``` html
112112
<div v-for="item of items"></div>
113113
```
114114

115115
### Template v-for
116116

117-
Similar to template `v-if`, you can also use a `<template>` tag with `v-for` to render a block of multiple elements. For example:
117+
如同 `v-if` 模板,你也可以用带有 `v-for``<template>` 标签来渲染多个元素块。例如:
118118

119119
``` html
120120
<ul>
@@ -125,9 +125,9 @@ Similar to template `v-if`, you can also use a `<template>` tag with `v-for` to
125125
</ul>
126126
```
127127

128-
### Object v-for
128+
### 对象迭代 v-for
129129

130-
You can also use `v-for` to iterate through the properties of an object.
130+
你也可以用 `v-for` 通过一个对象的属性来迭代。
131131

132132
``` html
133133
<ul id="repeat-object" class="demo">
@@ -150,7 +150,7 @@ new Vue({
150150
})
151151
```
152152

153-
Result:
153+
结果:
154154

155155
{% raw %}
156156
<ul id="repeat-object" class="demo">
@@ -172,35 +172,35 @@ new Vue({
172172
</script>
173173
{% endraw %}
174174

175-
You can also provide a second argument for the key:
175+
你也可以提供第二个的参数为键名:
176176

177177
``` html
178178
<div v-for="(value, key) in object">
179179
{{ key }} : {{ value }}
180180
</div>
181181
```
182182

183-
And another for the index:
183+
第三个参数为索引:
184184

185185
``` html
186186
<div v-for="(value, key, index) in object">
187187
{{ index }}. {{ key }} : {{ value }}
188188
</div>
189189
```
190190

191-
<p class="tip">When iterating over an object, the order is based on the key enumeration order of `Object.keys()`, which is **not** guaranteed to be consistent across JavaScript engine implementations.</p>
191+
<p class="tip">当遍历一个对象时,顺序是根据 `Object.keys()` 可枚举键名排列,不保证和JavaScript引擎实现是一致的。</p>
192192

193-
### Range v-for
193+
### 整数迭代 v-for
194194

195-
`v-for` can also take an integer. In this case it will repeat the template that many times.
195+
`v-for` 也可以取整数。在这种情况下,它将重复多次模板
196196

197197
``` html
198198
<div>
199199
<span v-for="n in 10">{{ n }}</span>
200200
</div>
201201
```
202202

203-
Result:
203+
结果:
204204

205205
{% raw %}
206206
<div id="range" class="demo">
@@ -211,17 +211,17 @@ new Vue({ el: '#range' })
211211
</script>
212212
{% endraw %}
213213

214-
### Components and v-for
214+
### 组件 和 v-for
215215

216-
> This section assumes knowledge of [Components](/guide/components.html). Feel free to skip it and come back later.
216+
> 了解组件相关知识,查看 [组件](/guide/components.html)
217217
218-
You can directly use `v-for` on a custom component, like any normal element:
218+
在自定义组件里,你可以像任何普通元素一样用 `v-for`
219219

220220
``` html
221221
<my-component v-for="item in items"></my-component>
222222
```
223223

224-
However, this won't automatically pass any data to the component, because components have isolated scopes of their own. In order to pass the iterated data into the component, we should also use props:
224+
然而,他不能自动传递数据到组件里
225225

226226
``` html
227227
<my-component

0 commit comments

Comments
 (0)