Skip to content

Commit 02de657

Browse files
veabaKiritaniAyaka
andauthored
Apply suggestions from code review
Co-authored-by: 时瑶 <[email protected]>
1 parent 3d583df commit 02de657

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

src/api/sfc-script-setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ const post = await fetch(`/api/post/1`).then((r) => r.json())
479479
`async setup()` 必须与 [`Suspense`](/guide/built-ins/suspense.html) 组合使用,该特性目前仍处于实验阶段。我们计划在未来的版本中完成该特性并编写文档——但如果你现在就感兴趣,可以参考其[测试](https://github.com/vuejs/core/blob/main/packages/runtime-core/__tests__/components/Suspense.spec.ts)来了解其工作方式。
480480
:::
481481

482-
## import 语句 {#imports-statements}
482+
## 导入语句 {#imports-statements}
483483

484-
vue 中的 import 语句遵循 [ECMAScript 模块规范](https://nodejs.org/api/esm.html)
484+
Vue 中的导入语句遵循 [ECMAScript 模块规范](https://nodejs.org/api/esm.html)
485485
此外,你还可以使用构建工具配置中定义的别名:
486486

487487
```vue

src/api/sfc-spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ p {{ msg }}
137137
```
138138

139139
:::warning 注意
140-
`src` 中使用别名时,不要以 `~` 开头,后面的任何内容都会被解释为模块请求。这意味着你可以在 node 模块中引用资产
140+
`src` 中使用别名时,不要以 `~` 开头,后面的任何内容都会被解释为模块请求。这意味着你可以引用 node 模块中的资源
141141
```vue
142142
<img src="~some-npm-package/foo.png">
143143
```

src/guide/essentials/event-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,6 @@ Vue 为一些常用的按键提供了别名:
348348

349349
这些修饰符将处理程序限定为由特定鼠标按键触发的事件。
350350

351-
但请注意,`.left``.right``.middle` 这些修饰符名称是基于常见的右手用鼠标布局设定的,但实际上它们分别代表“主”、”次“,“辅助”指向设备的事件触发,而非实际的物理按键。因此,对于左手用鼠标布局而言,“主”按键在物理上可能是右边的按键,但却会触发 `.left` 修饰符对应的处理程序。又或者,触控板可能通过单指点击触发 `.left` 处理程序,通过双指点击触发 `.right` 处理程序,通过三指点击触发 `.middle` 处理程序。同样,产生“鼠标”事件的其他设备和事件源,也可能具有与“左”,“右”完全无关的触发模式。
351+
但请注意,`.left``.right``.middle` 这些修饰符名称是基于常见的右手用鼠标布局设定的,但实际上它们分别指代设备事件触发器的“主”、”次“,“辅助”,而非实际的物理按键。因此,对于左手用鼠标布局而言,“主”按键在物理上可能是右边的按键,但却会触发 `.left` 修饰符对应的处理程序。又或者,触控板可能通过单指点击触发 `.left` 处理程序,通过双指点击触发 `.right` 处理程序,通过三指点击触发 `.middle` 处理程序。同样,产生“鼠标”事件的其他设备和事件源,也可能具有与“左”,“右”完全无关的触发模式。
352352

353353
<!-- zhlint disabled -->

src/guide/essentials/template-refs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ onMounted(() => console.log(itemRefs.value))
148148
<details>
149149
<summary>3.5 前的用法</summary>
150150

151-
In versions before 3.5 where `useTemplateRef()` was not introduced, we need to declare a ref with a name that matches the template ref attribute's value. The ref should also contain an array value:
151+
3.5 版本以前,`useTemplateRef()` 尚未引入,需要声明一个与模板引用 attribute 同名的 ref。该 ref 的值需要是一个数组。
152152

153153
```vue
154154
<script setup>

src/guide/extras/web-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function MyComponent() {
270270
}
271271
```
272272

273-
### 基于 Web Components 和 TypeScript {#web-components-and-typescript}
273+
### 基于 Vue 的 Web Components 和 TypeScript {#web-components-and-typescript}
274274

275275
在编写 Vue SFC 模板时,你可能想要为你的 Vue 组件添加[类型检查](/guide/scaling-up/tooling.html#typescript),包括那些被定义为自定义元素的组件。
276276

src/guide/reusability/custom-directives.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const vHighlight = {
3131

3232
```vue
3333
<script setup>
34-
// enables v-highlight in templates
34+
// 在模板中启用 v-highlight
3535
const vHighlight = {
3636
mounted: (el) => {
3737
el.classList.add('is-highlight')
@@ -55,7 +55,7 @@ const highlight = {
5555

5656
export default {
5757
directives: {
58-
// enables v-highlight in template
58+
// 在模板中启用 v-highlight
5959
highlight
6060
}
6161
}
@@ -73,17 +73,17 @@ export default {
7373

7474
<div class="composition-api">
7575

76-
In `<script setup>`, any camelCase variable that starts with the `v` prefix can be used as a custom directive. In the example above, `vHighlight` can be used in the template as `v-highlight`.
76+
`<script setup>` 中,任何以 `v` 开头的驼峰式命名的变量都可以当作自定义指令使用。在上述例子中,`vHighlight` 可以在模板中以 `v-highlight`的形式使用。
7777

78-
If you are not using `<script setup>`, custom directives can be registered using the `directives` option:
78+
在不使用 `<script setup>` 的情况下,自定义指令需要通过 `directives` 选项注册:
7979

8080
```js
8181
export default {
8282
setup() {
8383
/*...*/
8484
},
8585
directives: {
86-
// enables v-highlight in template
86+
// 在模板中启用 v-highlight
8787
highlight: {
8888
/* ... */
8989
}
@@ -95,26 +95,26 @@ export default {
9595

9696
<div class="options-api">
9797

98-
Similar to components, custom directives must be registered so that they can be used in templates. In the example above, we are using local registration via the `directives` option.
98+
和组件类似,自定义指令在模板中使用前必须先注册。在上面的例子中,我们使用 `directives` 选项完成了指令的局部注册。
9999

100100
</div>
101101

102-
It is also common to globally register custom directives at the app level:
102+
将一个自定义指令全局注册到应用层级也是一种常见的做法:
103103

104104
```js
105105
const app = createApp({})
106106

107-
// make v-highlight usable in all components
107+
// 使 v-highlight 在所有组件中都可用
108108
app.directive('highlight', {
109109
/* ... */
110110
})
111111
```
112112

113113
## When to use custom directives {#when-to-use}
114114

115-
Custom directives should only be used when the desired functionality can only be achieved via direct DOM manipulation.
115+
只有当所需功能只能通过直接的 DOM 操作来实现时,才应该使用自定义指令。
116116

117-
A common example of this is a `v-focus` custom directive that brings an element into focus.
117+
一个常见例子是使元素获取焦点的 `v-focus` 指令。
118118

119119
<div class="composition-api">
120120

@@ -156,7 +156,7 @@ export default {
156156

157157
该指令比 `autofocus` 属性更有用,因为它不仅在页面加载时有效,而且在 Vue 动态插入元素时也有效!
158158

159-
在可能的情况下,建议使用内置指令如 `v-bind` 进行声明式模板,因为它们更高效,对服务器渲染也更友好
159+
建议尽可能使用 `v-bind` 等内置指令声明模板,因为它们更高效,对服务端渲染也更友好
160160

161161
## 指令钩子 {#directive-hooks}
162162

src/guide/reusability/plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,6 @@ export default {
136136

137137
</div>
138138

139-
### Bundle for NPM
139+
### NPM 打包
140140

141-
If you further want to build and publish your plugin for others to use, see [Vite's section on Library Mode](https://vitejs.dev/guide/build.html#library-mode).
141+
如果你想进一步打包并发布插件给他人使用,请参阅 [Vite 库模式](https://vitejs.dev/guide/build.html#library-mode)

src/guide/scaling-up/testing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ Vitest 和基于浏览器的运行器之间的主要区别是速度和执行上
288288

289289
### 推荐方案 {#recommendation-2}
290290

291-
- [Playwright](https://playwright.dev/) 也是一个非常好的端到端测试解决方案,支持所有的现代渲染引擎,包括 Chromium、WebKit 和 Firefox。在 Windows、Linux 和 macOS 上进行本地或 CI 测试、无头测试,或使用适用于 Android 和 Mobile Safari 的 Google Chrome 的原生移动端模拟测试。它拥有信息丰富的用户界面、出色的调试能力、内置断言、并行处理功能以及追踪功能,旨在消除不稳定的测试。它还提供对[组件测试](https://docs.cypress.io/guides/component-testing/introduction)的支持,目前实验阶段。Playwright 由微软开源维护
291+
- [Playwright](https://playwright.dev/) 是一个非常好的端到端测试解决方案,支持 Chromium、WebKit 和 Firefox。在 Windows、Linux 和 macOS 上进行本地或 CI 测试、无头测试,或使用适用于 Android 和 Mobile Safari 的 Google Chrome 的原生移动端模拟测试。它拥有信息丰富的用户界面、出色的调试能力、内置断言、并行处理功能以及追踪功能,旨在消除不稳定的测试。它还提供对[组件测试](https://docs.cypress.io/guides/component-testing/introduction)的支持,但目前处于实验阶段。Playwright 由微软开源并维护
292292

293-
- [Cypress](https://www.cypress.io/) 具有信息丰富的图形界面、出色的调试性、内置断言、存根、抗剥落性、并行化和快照等诸多特性。而且如上所述,它还提供对 [组件测试](https://docs.cypress.io/guides/component-testing/introduction) 的支持。它支持基于 Chromium 的浏览器、Firefox 和 Electron。但 WebKit 被标记为实验性支持。Cypress 采用 MIT 许可,但某些功能,如并行化,需要订阅 Cypress Cloud。
293+
- [Cypress](https://www.cypress.io/) 具有信息丰富的图形界面、出色的调试性、内置断言、存根、抗剥落性、并行化和快照等诸多特性。而且如上所述,它还提供对 [组件测试](https://docs.cypress.io/guides/component-testing/introduction) 的支持。它支持基于 Chromium 的浏览器、Firefox 和 Electron。但 WebKit 被标记为实验性支持。Cypress 采用 MIT 许可,但并行化等部分功能需要订阅 Cypress Cloud。
294294

295295
<div class="lambdatest">
296296
<a href="https://lambdatest.com" target="_blank">

0 commit comments

Comments
 (0)