Skip to content

Commit 2baeb2f

Browse files
author
勾股
committed
translated forms
1 parent d73b8f4 commit 2baeb2f

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

source/guide/forms.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ type: guide
33
order: 7
44
---
55

6-
## The Basics
6+
## 基本用法
77

8-
You can use the `v-model` directive to create two-way data bindings on form input elements. It automatically picks the correct way to update the element based on the input type.
8+
你可以在表单的 input 元素上使用 `v-model` 指令来创建双向数据绑定。它会根据 input type 自动选取正确的方式更新元素。
99

10-
**Example**
10+
**示例**
1111

1212
``` html
1313
<form id="demo">
@@ -61,7 +61,7 @@ new Vue({
6161
})
6262
```
6363

64-
**Result**
64+
**效果**
6565

6666
<form id="demo"><p><input type="text" v-model="msg"> {&#123;msg&#125;}</p><p><input type="checkbox" v-model="checked"> {&#123;checked ? &quot;yes&quot; : &quot;no&quot;&#125;}</p><p><input type="radio" v-model="picked" name="picked" value="one"><input type="radio" v-model="picked" name="picked" value="two"> {&#123;picked&#125;}</p><p><select v-model="selected"><option>one</option><option>two</option></select> {&#123;selected&#125;}</p><p><select v-model="multiSelect" multiple><option>one</option><option>two</option><option>three</option></select>{&#123;multiSelect&#125;}</p><p>data:<pre style="font-size:13px;background:transparent;line-height:1.5em">{&#123;$data | json 2&#125;}</pre></p></form>
6767
<script>
@@ -77,34 +77,34 @@ new Vue({
7777
})
7878
</script>
7979

80-
## Lazy Updates
80+
## 懒更新
8181

82-
By default, `v-model` syncs the input with the data after each `input` event. You can add a `lazy` attribute to change the behavior to sync after `change` events:
82+
默认情况下,`v-model` 会在每个 `input` 事件之后同步输入的数据。你可以添加一个 `lazy` 特性,将其改变为在每个 `change` 事件之后才完成同步。
8383

8484
``` html
8585
<!-- synced after "change" instead of "input" -->
8686
<input v-model="msg" lazy>
8787
```
8888

89-
## Casting Value as Number
89+
## 当做数来处理
9090

91-
If you want user input to be automatically persisted as numbers, you can add a `number` attribute to your `v-model` managed inputs:
91+
如果你希望用户的输入自动处理为一个数,你可以在 `v-model` 所在的 input 上添加一个 `number` 特性。
9292

9393
``` html
9494
<input v-model="age" number>
9595
```
9696

97-
## Dynamic Select Options
97+
## 动态 select 选项
9898

99-
When you need to dynamically render a list of options for a `<select>` element, it's recommended to use an `options` attribute together with `v-model`:
99+
当你需要为一个 `<select>` 元素动态渲染列表选项时,我们推荐 `options` `v-model` 特性配合使用:
100100

101101
``` html
102102
<select v-model="selected" options="myOptions"></select>
103103
```
104104

105-
In your data, `myOptions` should be an keypath/expression that points to an Array to use as its options. The Array can contain plain strings, or contain objects.
105+
在你的数据里,`myOptions` 应该是一个代表选项数组的路径/表达式。该数组可以包含普通字符串或对象。
106106

107-
The object can be in the format of `{text:'', value:''}`. This allows you to have the option text displayed differently from its underlying value:
107+
该数组里对象的格式可以是 `{text:'', value:''}`。这允许你把展示的文字和其背后对应的值区分开来。
108108

109109
``` js
110110
[
@@ -113,7 +113,7 @@ The object can be in the format of `{text:'', value:''}`. This allows you to hav
113113
]
114114
```
115115

116-
Will render:
116+
会渲染成:
117117

118118
``` html
119119
<select>
@@ -122,7 +122,8 @@ Will render:
122122
</select>
123123
```
124124

125-
Alternatively, the object can be in the format of `{ label:'', options:[...] }`. In this case it will be rendered as an `<optgroup>`:
125+
<!-- Alternatively, the object can be in the format of `{ label:'', options:[...] }`. In this case it will be rendered as an `<optgroup>`:
126+
-->另外,该数组里对象的格式也可以是 `{label:'', options:[...]}`。这样的数据会被渲染成为一个 `<optgroup>`:
126127

127128
``` js
128129
[
@@ -131,7 +132,7 @@ Alternatively, the object can be in the format of `{ label:'', options:[...] }`.
131132
]
132133
```
133134

134-
Will render:
135+
会渲染成:
135136

136137
``` html
137138
<select>
@@ -146,4 +147,4 @@ Will render:
146147
</select>
147148
```
148149

149-
Next: [Computed Properties](../guide/computed.html).
150+
接下来:[可推导的属性](../guide/computed.html).

0 commit comments

Comments
 (0)