Skip to content

Commit 6a5c6cb

Browse files
huyikaiJustineo
andauthored
docs: Update translate src/guide/components/v-model.md (#849)
Co-authored-by: GU Yiling <justice360@gmail.com>
1 parent 0acaa3d commit 6a5c6cb

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/guide/components/v-model.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ export default {
174174

175175
## `v-model` 的参数 {#v-model-arguments}
176176

177-
`v-model` on a component can also accept an argument:
177+
组件上的 `v-model` 也可以接受一个参数:
178178

179179
```vue-html
180180
<MyComponent v-model:title="bookTitle" />
181181
```
182182

183183
<div class="composition-api">
184184

185-
In the child component, we can support the corresponding argument by passing a string to `defineModel()` as its first argument:
185+
在子组件中,我们可以通过将字符串作为第一个参数传递给 `defineModel()` 来支持相应的参数:
186186

187187
```vue
188188
<!-- MyComponent.vue -->
@@ -195,9 +195,9 @@ const title = defineModel('title')
195195
</template>
196196
```
197197

198-
[Try it in the Playground](https://play.vuejs.org/#eNqFkl9PwjAUxb9K05dhglsMb2SQqOFBE9Soj31Zxh0Uu7bpHxxZ9t29LWOiQXzaes7p2a+9a+mt1unOA53S3JaGa0csOK/nTPJaK+NISwxUpCOVUTVJMJoM1nJ/r/BNgnS9nWYnWujFMCFMlkpaRxx3AsgsFI6S3XWtViBIYda+Dg3QFLUWkFwxmWcHFqTAhQPUCwe4IiTf3Mzbtq/qujzDddRPYfruaUzNGI1PRkmG0Twb+uiY/sI9cw0/0VdQcQnL0D5KovgfL5fa4/69jiDQOOTo+S6SOYtfrvg63VolkauNN0lLxOUCzLN2HMkYnZLoBK8QQn0+Rs0ZD+OjXm6g/Dijb20TNEZfDFgwOwQZPIdzAWQN9uLtKXIPJtL7gH3BfAWrhA+Mh9idlyvEPslF2of4J3G5freLxoG0x0MF0JDsYp5RHE6Y1F9H/8adpJO4j8mOdl/Hw/nf)
198+
[在演练场中尝试一下](https://play.vuejs.org/#eNqFkl9PwjAUxb9K05dhglsMb2SQqOFBE9Soj31Zxh0Uu7bpHxxZ9t29LWOiQXzaes7p2a+9a+mt1unOA53S3JaGa0csOK/nTPJaK+NISwxUpCOVUTVJMJoM1nJ/r/BNgnS9nWYnWujFMCFMlkpaRxx3AsgsFI6S3XWtViBIYda+Dg3QFLUWkFwxmWcHFqTAhQPUCwe4IiTf3Mzbtq/qujzDddRPYfruaUzNGI1PRkmG0Twb+uiY/sI9cw0/0VdQcQnL0D5KovgfL5fa4/69jiDQOOTo+S6SOYtfrvg63VolkauNN0lLxOUCzLN2HMkYnZLoBK8QQn0+Rs0ZD+OjXm6g/Dijb20TNEZfDFgwOwQZPIdzAWQN9uLtKXIPJtL7gH3BfAWrhA+Mh9idlyvEPslF2of4J3G5freLxoG0x0MF0JDsYp5RHE6Y1F9H/8adpJO4j8mOdl/Hw/nf)
199199

200-
If prop options are also needed, they should be passed after the model name:
200+
如果需要额外的 prop 选项,应该在 model 名称之后传递:
201201

202202
```js
203203
const title = defineModel('title', { required: true })
@@ -355,7 +355,7 @@ export default {
355355

356356
<div class="composition-api">
357357

358-
Modifiers added to a component `v-model` can be accessed in the child component by destructuring the `defineModel()` return value like this:
358+
通过像这样解构 `defineModel()` 的返回值,可以在子组件中访问添加到组件 `v-model` 的修饰符:
359359

360360
```vue{4}
361361
<script setup>
@@ -369,7 +369,7 @@ console.log(modifiers) // { capitalize: true }
369369
</template>
370370
```
371371

372-
To conditionally adjust how the value should be read / written based on modifiers, we can pass `get` and `set` options to `defineModel()`. These two options receive the value on get / set of the model ref and should return a transformed value. This is how we can use the `set` option to implement the `capitalize` modifier:
372+
为了能够基于修饰符选择性地调节值的读取和写入方式,我们可以给 `defineModel()` 传入 `get``set` 这两个选项。这两个选项在从模型引用中读取或设置值时会接收到当前的值,并且它们都应该返回一个经过处理的新值。下面是一个例子,展示了如何利用 `set` 选项来应用 `capitalize` (首字母大写) 修饰符:
373373

374374
```vue{6-8}
375375
<script setup>

0 commit comments

Comments
 (0)