Skip to content

Commit 2ac7185

Browse files
pakchoilySkyeYoungwxsmsJinjiang
authored
docs(api): translation src/api/render-function.md completed (vuejs#243)
* fix: class="vt-badge ts|experimental" can't render,Consistent with the English version * update: multiple translation verification * fix: add `v-slot` like English version * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: SkyeYoung <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: wxsm <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md Co-authored-by: wxsm <[email protected]> * Update src/guide/essentials/template-syntax.md Co-authored-by: wxsm <[email protected]> * Update src/guide/essentials/reactivity-fundamentals.md * api/ssr.md done * Apply suggestions from code review * Update ssr.md * wip: translate to `isVNode()` * translate: src/api/render-function.md done * Apply suggestions from code review Co-authored-by: SkyeYoung <[email protected]> Co-authored-by: wxsm <[email protected]> Co-authored-by: Jinjiang <[email protected]>
1 parent f6f1f1a commit 2ac7185

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

src/api/render-function.md

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Render Function APIs
1+
# 渲染函数 API {#render-function-APIs}
22

3-
## h()
3+
## h() {#h}
44

5-
Creates virtual DOM nodes (vnodes).
5+
创建虚拟 DOM 节点 (vnode)。
66

77
- **类型**
88

99
```ts
10-
// full signature
10+
// 完整参数签名
1111
function h(
1212
type: string | Component,
1313
props?: object | null,
1414
children?: Children | Slot | Slots
1515
): VNode
1616

17-
// omitting props
17+
// 省略 props
1818
function h(type: string | Component, children?: Children | Slot): VNode
1919

2020
type Children = string | number | boolean | VNode | null | Children[]
@@ -28,76 +28,76 @@ Creates virtual DOM nodes (vnodes).
2828
2929
- **详细信息**
3030
31-
The first argument can either be a string (for native elements) or a Vue component definition. The second argument is the props to be passed, and the third argument is the children.
31+
第一个参数既可以是一个字符串 (用于原生元素) 也可以是一个 Vue 组件定义。第二个参数是要传递的 prop,第三个参数是子节点。
3232
33-
When creating a component vnode, the children must be passed as slot functions. A single slot function can be passed if the component expects only the default slot. Otherwise, the slots must be passed as an object of slot functions.
33+
当创建一个组件的 vnode 时,子节点必须以插槽函数进行传递。如果组件只有默认槽,可以使用单个插槽函数进行传递。否则,必须以插槽函数的对象形式来传递。
3434
35-
For convenience, the props argument can be omitted when the children is not a slots object.
35+
为了方便阅读,当子节点不是插槽对象时,可以省略 prop 参数。
3636
3737
- **示例**
3838
39-
Creating native elements:
39+
创建原生元素:
4040
4141
```js
4242
import { h } from 'vue'
4343

44-
// all arguments except the type are optional
44+
// 除了 type 外,其他参数都是可选的
4545
h('div')
4646
h('div', { id: 'foo' })
4747

48-
// both attributes and properties can be used in props
49-
// Vue automatically picks the right way to assign it
48+
// attribute 和 property 都可以用于 prop
49+
// Vue 会自动选择正确的方式来分配它
5050
h('div', { class: 'bar', innerHTML: 'hello' })
5151

52-
// class and style have the same object / array
53-
// value support like in templates
52+
// class style 可以像在模板中一样
53+
// 用数组或对象的形式书写
5454
h('div', { class: [foo, { bar }], style: { color: 'red' } })
5555

56-
// event listeners should be passed as onXxx
56+
// 事件监听器应以 onXxx 的形式书写
5757
h('div', { onClick: () => {} })
5858

59-
// children can be a string
59+
// children 可以是一个字符串
6060
h('div', { id: 'foo' }, 'hello')
6161

62-
// props can be omitted when there are no props
62+
// 没有 prop 时可以省略不写
6363
h('div', 'hello')
6464
h('div', [h('span', 'hello')])
6565

66-
// children array can contain mixed vnodes and strings
66+
// children 数组可以同时包含 vnode 和字符串
6767
h('div', ['hello', h('span', 'hello')])
6868
```
6969

70-
Creating components:
70+
创建组件:
7171

7272
```js
7373
import Foo from './Foo.vue'
7474

75-
// passing props
75+
// 传递 prop
7676
h(Foo, {
77-
// equivalent of some-prop="hello"
77+
// 等价于 some-prop="hello"
7878
someProp: 'hello',
79-
// equivalent of @update="() => {}"
79+
// 等价于 @update="() => {}"
8080
onUpdate: () => {}
8181
})
8282

83-
// passing single default slot
83+
// 传递单个默认插槽
8484
h(Foo, () => 'default slot')
8585

86-
// passing named slots
87-
// notice the `null` is required to avoid
88-
// slots object being treated as props
86+
// 传递具名插槽
87+
// 注意,需要使用 `null` 来避免
88+
// 插槽对象被当作是 prop
8989
h(MyComponent, null, {
9090
default: () => 'default slot',
9191
foo: () => h('div', 'foo'),
9292
bar: () => [h('span', 'one'), h('span', 'two')]
9393
})
9494
```
9595

96-
- **相关内容** [Guide - Creating VNodes](/guide/extras/render-function.html#creating-vnodes)
96+
- **相关内容**[指南 - 创建 VNode](/guide/extras/render-function.html#creating-vnodes)
9797

98-
## mergeProps()
98+
## mergeProps() {#mergeprops}
9999

100-
Merge multiple props objects with special handling for certain props.
100+
合并多个 prop 对象,用于处理含有特定的 prop 参数的情况。
101101

102102
- **类型**
103103

@@ -107,13 +107,13 @@ Merge multiple props objects with special handling for certain props.
107107

108108
- **详细信息**
109109

110-
`mergeProps()` supports merging multiple props objects with special handling for the following props:
110+
`mergeProps()` 支持以下特定 prop 参数的处理,将它们合并成一个对象。
111111

112112
- `class`
113113
- `style`
114-
- `onXxx` event listeners - multiple listeners with the same name will be merged into an array.
114+
- `onXxx` 事件监听器——多个同名的事件监听器将被合并到一个数组。
115115

116-
If you do not need the merge behavior and want simple overwrites, native object spread can be used instead.
116+
如果你不需要合并行为而是简单覆盖,可以使用原生 object spread 语法来代替。
117117

118118
- **示例**
119119

@@ -139,9 +139,9 @@ Merge multiple props objects with special handling for certain props.
139139
*/
140140
```
141141

142-
## cloneVNode()
142+
## cloneVNode() {#clonevnode}
143143

144-
Clones a vnode.
144+
克隆一个 vnode
145145

146146
- **类型**
147147

@@ -151,11 +151,11 @@ Clones a vnode.
151151

152152
- **详细信息**
153153

154-
Returns a cloned vnode, optionally with extra props to merge with the original.
154+
返回一个克隆的 vnode,可在原有基础上添加一些额外的 prop
155155

156-
Vnodes should be considered immutable once created, and you should not mutate the props of an existing vnode. Instead, clone it with different / extra props.
156+
Vnode 被认为是一旦创建就不能修改的,你不应该修改已创建的 vnodeprop,而应该附带不同的/额外的 prop 来克隆它。
157157

158-
Vnodes have special internal properties, so cloning them is not as simple as an object spread. `cloneVNode()` handles most of the internal logic.
158+
Vnode 具有特殊的内部 property ,因此克隆它并不像 object spread 一样简单。 `cloneVNode()` 处理了大部分这样的内部逻辑。
159159

160160
- **示例**
161161

@@ -166,19 +166,19 @@ Clones a vnode.
166166
const cloned = cloneVNode(original, { id: 'foo' })
167167
```
168168

169-
## isVNode()
169+
## isVNode() {#isvnode}
170170

171-
Checks if a value is a vnode.
171+
判断一个值是否为 vnode 类型。
172172

173173
- **类型**
174174

175175
```ts
176176
function isVNode(value: unknown): boolean
177177
```
178178

179-
## resolveComponent()
179+
## resolveComponent() {#resolvecomponent}
180180

181-
For manually resolving a registered component by name.
181+
按名称手动解析已注册的组件。
182182

183183
- **类型**
184184

@@ -188,11 +188,11 @@ For manually resolving a registered component by name.
188188

189189
- **详细信息**
190190

191-
**Note: you do not need this if you can import the component directly.**
191+
**备注:如果你可以直接引入组件就不需使用此方法。**
192192

193-
`resolveComponent()` must be called inside<span class="composition-api"> either `setup()` or</span> the render function in order to resolve from the correct component context.
193+
为了能从正确的组件上下文进行解析,`resolveComponent()` 必须在<span class="composition-api"> `setup()` </span>渲染函数内调用。
194194

195-
If the component is not found, a runtime warning will be emitted, and the name string is returned.
195+
如果组件未找到,会抛出一个运行时警告,并返回组件名字符串。
196196

197197
- **示例**
198198

@@ -228,11 +228,11 @@ For manually resolving a registered component by name.
228228

229229
</div>
230230

231-
- **相关内容** [Guide - Render Functions - Components](/guide/extras/render-function.html#components)
231+
- **相关内容**:[指南 - 渲染函数 - 组件](/guide/extras/render-function.html#components)
232232

233-
## resolveDirective()
233+
## resolveDirective() {#resolvedirective}
234234

235-
For manually resolving a registered directive by name.
235+
按名称手动解析已注册的指令。
236236

237237
- **类型**
238238

@@ -242,17 +242,17 @@ For manually resolving a registered directive by name.
242242

243243
- **详细信息**
244244

245-
**Note: you do not need this if you can import the component directly.**
245+
**备注:如果你可以直接引入组件就不需使用此方法。**
246246

247-
`resolveDirective()` must be called inside<span class="composition-api"> either `setup()` or</span> the render function in order to resolve from the correct component context.
247+
为了能从正确的组件上下文进行解析,`resolveDirective()` 必须在<span class="composition-api"> `setup()` </span>渲染函数内调用。
248248

249-
If the directive is not found, a runtime warning will be emitted, and the function returns `undefined`.
249+
如果指令没有找到,会抛出一个运行时警告,并返回 `undefined`
250250

251-
- **相关内容** [Guide - Render Functions - Custom Directives](/guide/extras/render-function.html#custom-directives)
251+
- **相关内容**:[指南 - 渲染函数 - 自定义指令](/guide/extras/render-function.html#custom-directives)
252252

253-
## withDirectives()
253+
## withDirectives() {#withdirectives}
254254

255-
For adding custom directives to vnodes.
255+
用于给 vnode 增加自定义指令。
256256

257257
- **类型**
258258

@@ -273,14 +273,14 @@ For adding custom directives to vnodes.
273273

274274
- **详细信息**
275275

276-
Wraps an existing vnode with custom directives. The second argument is an array of custom directives. Each custom directive is also represented as an array in the form of `[Directive, value, argument, modifiers]`. Tailing elements of the array can be omitted if not needed.
276+
用自定义指令包装一个现有的 vnode 。第二个参数是自定义指令数组。每个自定义指令也可以表示为 `[Directive, value, argument, modifiers]` 形式的数组。如果不需要,可以省略数组的尾元素。
277277

278278
- **示例**
279279

280280
```js
281281
import { h, withDirectives } from 'vue'
282282
283-
// a custom directive
283+
// 一个自定义指令
284284
const pin = {
285285
mounted() {
286286
/* ... */
@@ -296,11 +296,11 @@ For adding custom directives to vnodes.
296296
])
297297
```
298298

299-
- **相关内容:** [Guide - Render Functions - Custom Directives](/guide/extras/render-function.html#custom-directives)
299+
- **相关内容**:[指南 - 渲染函数 - 自定义指令](/guide/extras/render-function.html#custom-directives)
300300

301-
## withModifiers()
301+
## withModifiers() {#withmodifiers}
302302

303-
For adding built-in [`v-on` modifiers](/guide/essentials/event-handling.html#event-modifiers) to an event handler function.
303+
用于向事件处理函数添加内置 [`v-on` 修饰符](/guide/essentials/event-handling.html#event-modifiers)
304304

305305
- **类型**
306306

@@ -314,11 +314,11 @@ For adding built-in [`v-on` modifiers](/guide/essentials/event-handling.html#eve
314314
import { h, withModifiers } from 'vue'
315315
316316
const vnode = h('button', {
317-
// equivalent of v-on.stop.prevent
317+
// 等价于 v-on.stop.prevent
318318
onClick: withModifiers(() => {
319319
// ...
320320
}, ['stop', 'prevent'])
321321
})
322322
```
323323

324-
- **相关内容:** [Guide - Render Functions - Event Modifiers](/guide/extras/render-function.html#event-modifiers)
324+
- **相关内容**:[指南 - 渲染函数 - 事件修饰符](/guide/extras/render-function.html#event-modifiers)

0 commit comments

Comments
 (0)