-
Notifications
You must be signed in to change notification settings - Fork 846
docs: update reactive translation #52
Changes from 1 commit
f3b56be
197586b
0cd4b5c
5076aa8
ed9081f
f0f90eb
e8533cd
beeab24
7ffa80b
2c66941
85d26ab
5841adf
a3302fd
c40b3b6
e46394f
5aff52f
24ef587
ec7c310
2c27dca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,11 +9,11 @@ | |||||
|
||||||
## 控制更新 | ||||||
|
||||||
感谢 Vue 的反应系统,它总是知道什么时候更新 (如果你使用正确的话)。但是,在某些边缘情况下,你可能希望强制更新,尽管事实上没有任何反应性数据发生更改。还有一些情况下,你可能希望防止不必要的更新。 | ||||||
感谢 Vue 的响应式系统,它总是知道什么时候更新 (如果你使用正确的话)。但是,在某些边缘情况下,你可能希望强制更新,尽管事实上没有任何响应式数据发生更改。还有一些情况下,你可能希望防止不必要的更新。 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
### 强制更新 | ||||||
|
||||||
如果你发现自己需要在 Vue 中强制更新,在 99.99%的情况下,你在某个地方犯了错误。例如,你可能依赖于 Vue 反应性系统未跟踪的状态,例如,在组件创建之后添加了 `data` 属性。 | ||||||
如果你发现自己需要在 Vue 中强制更新,在 99.99%的情况下,你在某个地方犯了错误。例如,你可能依赖于 Vue 响应式系统未跟踪的状态,例如,在组件创建之后添加了 `data` 属性。 | ||||||
|
||||||
但是,如果你已经排除了上述情况,并且发现自己处于这种非常罕见的情况下,必须手动强制更新,那么你可以使用 [`$forceUpdate`](../api/instance-methods.html#forceupdate)。 | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -97,7 +97,7 @@ app.component('todo-list', { | |||||||||||||||
|
||||||||||||||||
## 与响应式一起工作 | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
你这么一说,我自己都糊涂了,:joy: 我摘了英文版 实际例子来对比下。
好像也说的过去, |
||||||||||||||||
|
||||||||||||||||
在上面的例子中,如果我们更改了 `todos` 的列表,这个更改将不会反映在注入的 `todoLength` property 中。这是因为默认情况下,`provide/inject` 绑定*不*是被动绑定。我们可以通过将 `ref` property 或 `reactive` 对象传递给 `provide` 来更改此行为。在我们的例子中,如果我们想对祖先组件中的更改做出反应,我们需要为我们提供的 `todoLength` 分配一个组合 API `computed` property: | ||||||||||||||||
在上面的例子中,如果我们更改了 `todos` 的列表,这个更改将不会反映在注入的 `todoLength` property 中。这是因为默认情况下,`provide/inject` 绑定*不*是被动绑定。我们可以通过将 `ref` property 或 `reactive` 对象传递给 `provide` 来更改此行为。在我们的例子中,如果我们想对祖先组件中的更改做出响应,我们需要为我们提供的 `todoLength` 分配一个组合 API `computed` property: | ||||||||||||||||
|
||||||||||||||||
```js | ||||||||||||||||
app.component('todo-list', { | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ export default { | |
``` | ||
|
||
:::warning | ||
但是,因为 `props` 是响应性的,你不能**使用 ES6 解构**,因为它会消除 prop 的反应性。 | ||
但是,因为 `props` 是响应性的,你不能**使用 ES6 解构**,因为它会消除 prop 的响应式。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
::: | ||
|
||
如果需要销毁 prop,可以通过使用 `setup` 函数中的 [toRefs](reactivity-fundamentals.html#destructuring-reactive-state) 来安全地完成此操作。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.