Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: GU Yiling <[email protected]>
  • Loading branch information
wxsms and Justineo committed May 8, 2024
1 parent 094a01e commit c150587
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/api/component-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
- **详细信息**
第一个参数是侦听来源。可以是一个组件的属性名的字符串,一个简单的由点分隔的路径字符串,或是一个 [getter 函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description)。
第一个参数是侦听来源。可以是一个组件的属性名的字符串,一个简单的由点分隔的路径字符串,或是一个 [getter 函数](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/get#description)。
第二个参数是回调函数。它接收的参数分别是侦听来源的新值、旧值。
Expand Down
2 changes: 1 addition & 1 deletion src/api/reactivity-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

## computed() {#computed}

接受一个 [getter 函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set#description),返回一个只读的响应式 [ref](#ref) 对象。该 ref 通过 `.value` 暴露 getter 函数的返回值。它也可以接受一个带有 `get``set` 函数的对象来创建一个可写的 ref 对象。
接受一个 [getter 函数](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/set#description),返回一个只读的响应式 [ref](#ref) 对象。该 ref 通过 `.value` 暴露 getter 函数的返回值。它也可以接受一个带有 `get``set` 函数的对象来创建一个可写的 ref 对象。

- **类型**

Expand Down
2 changes: 1 addition & 1 deletion src/glossary/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ Vue 只能在响应式作用内部跟踪响应式依赖关系。如果在响应

实现一个响应性系统的方式有很多种。例如,可以通过代码的静态分析来确定其依赖关系。但是,Vue 没有采用这种形式的响应性系统。

取而代之的是,Vue 的响应性系统在运行时跟踪属性的访问。它通过结合 Proxy 包装器和 [getter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description)/[setter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/set#description) 函数来实现。
取而代之的是,Vue 的响应性系统在运行时跟踪属性的访问。它通过结合 Proxy 包装器和 [getter](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/get#description)/[setter](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/set#description) 函数来实现。

详见:
- [指南 - 响应式基础](/guide/essentials/reactivity-fundamentals.html)
Expand Down
2 changes: 1 addition & 1 deletion src/guide/built-ins/suspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Vue Router 使用动态导入对[懒加载组件](https://router.vuejs.org/zh/gu
```vue-html
<Suspense>
<component :is="DynamicAsyncOuter">
<Suspense suspensible> <!-- this -->
<Suspense suspensible> <!-- 像这样 -->
<component :is="DynamicAsyncInner" />
</Suspense>
</component>
Expand Down
2 changes: 1 addition & 1 deletion src/guide/essentials/computed.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const publishedBooksMessage = computed(() => {

[在演练场中尝试一下](https://play.vuejs.org/#eNp1kE9Lw0AQxb/KI5dtoTainkoaaREUoZ5EEONhm0ybYLO77J9CCfnuzta0vdjbzr6Zeb95XbIwZroPlMySzJW2MR6OfDB5oZrWaOvRwZIsfbOnCUrdmuCpQo+N1S0ET4pCFarUynnI4GttMT9PjLpCAUq2NIN41bXCkyYxiZ9rrX/cDF/xDYiPQLjDDRbVXqqSHZ5DUw2tg3zP8lK6pvxHe2DtvSasDs6TPTAT8F2ofhzh0hTygm5pc+I1Yb1rXE3VMsKsyDm5JcY/9Y5GY8xzHI+wnIpVw4nTI/10R2rra+S4xSPEJzkBvvNNs310ztK/RDlLLjy1Zic9cQVkJn+R7gIwxJGlMXiWnZEq77orhH3Pq2NH9DjvTfpfSBSbmA==)

我们在这里定义了一个计算属性 `publishedBooksMessage``computed()` 方法期望接收一个 [getter 函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description),返回值为一个**计算属性 ref**。和其他一般的 ref 类似,你可以通过 `publishedBooksMessage.value` 访问计算结果。计算属性 ref 也会在模板中自动解包,因此在模板表达式中引用时无需添加 `.value`
我们在这里定义了一个计算属性 `publishedBooksMessage``computed()` 方法期望接收一个 [getter 函数](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/get#description),返回值为一个**计算属性 ref**。和其他一般的 ref 类似,你可以通过 `publishedBooksMessage.value` 访问计算结果。计算属性 ref 也会在模板中自动解包,因此在模板表达式中引用时无需添加 `.value`

Vue 的计算属性会自动追踪响应式依赖。它会检测到 `publishedBooksMessage` 依赖于 `author.books`,所以当 `author.books` 改变时,任何依赖于 `publishedBooksMessage` 的绑定都会同时更新。

Expand Down
2 changes: 1 addition & 1 deletion src/guide/essentials/watchers.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ watch(question, async (newQuestion, oldQuestion) => {

### 侦听数据源类型 {#watch-source-types}

`watch` 的第一个参数可以是不同形式的“数据源”:它可以是一个 ref (包括计算属性)、一个响应式对象、一个 [getter 函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description)、或多个数据源组成的数组:
`watch` 的第一个参数可以是不同形式的“数据源”:它可以是一个 ref (包括计算属性)、一个响应式对象、一个 [getter 函数](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/get#description)、或多个数据源组成的数组:

```js
const x = ref(0)
Expand Down
2 changes: 1 addition & 1 deletion src/guide/reusability/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const { data, error } = useFetch(url)
url.value = '/new-url'
```

或者接收一个 [getter 函数](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description)
或者接收一个 [getter 函数](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/get#description)

```js
// 当 props.id 改变时重新 fetch
Expand Down

0 comments on commit c150587

Please sign in to comment.