Skip to content

Commit d001f06

Browse files
authored
docs: improve translation (#126)
* docs: improve translation * Update README.zh-CN.md * Update README.zh-CN.md
1 parent ea48e3e commit d001f06

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

README.zh-CN.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
- [TSX](#tsx)
1717
- [限制](#限制)
1818
- [API](https://vue-composition-api-rfc.netlify.com/api.html)
19-
- [Changelog](https://github.com/vuejs/composition-api/blob/master/CHANGELOG.md)
19+
- [更新日志](https://github.com/vuejs/composition-api/blob/master/CHANGELOG.md)
2020

2121
# 安装
2222

@@ -55,9 +55,9 @@ Vue.use(VueCompositionApi);
5555

5656
# TypeScript
5757

58-
**请使用最新版的 TypeScript,如果你使用了 `vetur`,请将 `vetur.useWorkspaceDependencies` 设为 `true`**
58+
**本插件要求使用 TypeScript 3.5.1 以上版本,如果你正在使用 `vetur`,请将 `vetur.useWorkspaceDependencies` 设为 `true`**
5959

60-
为了让 TypeScript 正确的推导类型,我们必须使用 `defineComponent` 来定义组件:
60+
为了让 TypeScript 在 Vue 组件选项中正确地推导类型,我们必须使用 `defineComponent` 来定义组件:
6161

6262
```ts
6363
import { defineComponent } from '@vue/composition-api';
@@ -79,7 +79,7 @@ const Component = {
7979
要支持 TSX,请创建一个类型定义文件并提供正确的 JSX 定义。内容如下:
8080

8181
```ts
82-
// file: shim-tsx.d.ts`
82+
// 文件: `shim-tsx.d.ts`
8383
import Vue, { VNode } from 'vue';
8484
import { ComponentRenderProxy } from '@vue/composition-api';
8585

@@ -90,7 +90,7 @@ declare global {
9090
// tslint:disable no-empty-interface
9191
interface ElementClass extends ComponentRenderProxy {}
9292
interface ElementAttributesProperty {
93-
$props: any; // specify the property name to use
93+
$props: any; // 定义要使用的属性名称
9494
}
9595
interface IntrinsicElements {
9696
[elem: string]: any;
@@ -101,21 +101,21 @@ declare global {
101101

102102
# 限制
103103

104-
## `Ref` Unwrap
104+
## `Ref` 自动展开 (unwrap)
105105

106-
数组索引属性无法进行自动的`Unwrap`:
106+
数组索引属性无法进行自动展开:
107107

108108
### **不要**使用 `Array` 直接存取 `ref` 对象:
109109

110110
```js
111111
const state = reactive({
112112
list: [ref(0)],
113113
});
114-
// no unwrap, `.value` is required
114+
// 不会自动展开, 须使用 `.value`
115115
state.list[0].value === 0; // true
116116

117117
state.list.push(ref(1));
118-
// no unwrap, `.value` is required
118+
// 不会自动展开, 须使用 `.value`
119119
state.list[1].value === 1; // true
120120
```
121121

@@ -126,23 +126,23 @@ const a = {
126126
count: ref(0),
127127
};
128128
const b = reactive({
129-
list: [a], // a.count will not unwrap!!
129+
list: [a], // `a.count` 不会自动展开!!
130130
});
131131

132-
// no unwrap for `count`, `.value` is required
132+
// `count` 不会自动展开, 须使用 `.value`
133133
b.list[0].count.value === 0; // true
134134
```
135135

136136
```js
137137
const b = reactive({
138138
list: [
139139
{
140-
count: ref(0), // no unwrap!!
140+
count: ref(0), // 不会自动展开!!
141141
},
142142
],
143143
});
144144

145-
// no unwrap for `count`, `.value` is required
145+
// `count` 不会自动展开, 须使用 `.value`
146146
b.list[0].count.value === 0; // true
147147
```
148148

@@ -155,15 +155,15 @@ const a = reactive({
155155
const b = reactive({
156156
list: [a],
157157
});
158-
// unwrapped
158+
// 自动展开
159159
b.list[0].count === 0; // true
160160

161161
b.list.push(
162162
reactive({
163163
count: ref(1),
164164
})
165165
);
166-
// unwrapped
166+
// 自动展开
167167
b.list[1].count === 1; // true
168168
```
169169

@@ -180,11 +180,11 @@ b.list[1].count === 1; // true
180180

181181
---
182182

183-
## Template Refs
183+
## 模板 Refs
184184

185-
> :white_check_mark: Support     :x: Not Support
185+
> :white_check_mark: 支持     :x: 不支持
186186
187-
:white_check_mark: String ref && return it from `setup()`:
187+
:white_check_mark: 字符串 ref && `setup()` 返回 ref:
188188

189189
```html
190190
<template>
@@ -197,7 +197,7 @@ b.list[1].count === 1; // true
197197
const root = ref(null);
198198
199199
onMounted(() => {
200-
// the DOM element will be assigned to the ref after initial render
200+
// 在初次渲染后 DOM 元素会被赋值给 ref
201201
console.log(root.value); // <div/>
202202
});
203203
@@ -209,15 +209,15 @@ b.list[1].count === 1; // true
209209
</script>
210210
```
211211

212-
:white_check_mark: String ref && return it from `setup()` && Render Function / JSX:
212+
:white_check_mark: 字符串 ref && `setup()` 返回 ref && 渲染函数 / JSX:
213213

214214
```jsx
215215
export default {
216216
setup() {
217217
const root = ref(null);
218218

219219
onMounted(() => {
220-
// the DOM element will be assigned to the ref after initial render
220+
// 在初次渲染后 DOM 元素会被赋值给 ref
221221
console.log(root.value); // <div/>
222222
});
223223

@@ -226,13 +226,13 @@ export default {
226226
};
227227
},
228228
render() {
229-
// with JSX
229+
// 使用 JSX
230230
return () => <div ref="root" />;
231231
},
232232
};
233233
```
234234

235-
:x: Function ref:
235+
:x: 函数 ref:
236236

237237
```html
238238
<template>
@@ -252,7 +252,7 @@ export default {
252252
</script>
253253
```
254254

255-
:x: Render Function / JSX:
255+
:x: 渲染函数 / JSX:
256256

257257
```jsx
258258
export default {
@@ -264,7 +264,7 @@ export default {
264264
ref: root,
265265
});
266266

267-
// with JSX
267+
// 使用 JSX
268268
return () => <div ref={root} />;
269269
},
270270
};
@@ -279,7 +279,7 @@ export default {
279279
setup(initProps, setupContext) {
280280
const refs = setupContext.refs;
281281
onMounted(() => {
282-
// the DOM element will be assigned to the ref after initial render
282+
// 在初次渲染后 DOM 元素会被赋值给 ref
283283
console.log(refs.root); // <div/>
284284
});
285285

@@ -288,7 +288,7 @@ export default {
288288
ref: 'root',
289289
});
290290

291-
// with JSX
291+
// 使用 JSX
292292
return () => <div ref="root" />;
293293
},
294294
};

0 commit comments

Comments
 (0)