This repository was archived by the owner on Aug 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 838
docs: translate reactive #218
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
39d1779
docs: translate reactive
veaba 5c8183c
update: src/guide/reactivity-computed-watchers.md
veaba 4577e31
update: src/api/basic-reactivity.md
veaba 46baad1
update: src/guide/composition-api-introduction.md
veaba e723225
update: src/guide/reactivity-computed-watchers.md
veaba 52960f7
update: src/api/basic-reactivity.md
veaba 5550522
Apply suggestions from code review
Jinjiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -203,7 +203,7 @@ type CustomRefFactory<T> = ( | |||||
|
||||||
```js | ||||||
const foo = shallowRef({}) | ||||||
// 改变ref的值是响应式的 | ||||||
// 改变 ref 的值是响应式的 | ||||||
foo.value = {} | ||||||
// 但是这个值不会被转换。 | ||||||
isReactive(foo.value) // false | ||||||
|
@@ -225,7 +225,7 @@ watchEffect(() => { | |||||
console.log(shallow.value.greet) | ||||||
}) | ||||||
|
||||||
// 这不会触发效果,因为ref很浅 | ||||||
// 这不会触发作用,因为 ref 很浅层 | ||||||
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
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. effect flush timing 之前译为了“副作用刷新时机”。那么单独的 effect 我们是否应该翻译成“副作用”? /cc @Jinjiang |
||||||
shallow.value.greet = 'Hello, universe' | ||||||
|
||||||
// 记录 "Hello, universe" | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,11 +9,11 @@ | |||||
|
||||||
## 控制更新 | ||||||
|
||||||
得益于其响应式系统,Vue 总是知道何时更新 (如果你使用正确的话)。但是,在某些边缘情况下,你可能希望强制更新,尽管事实上没有任何反应性数据发生更改。还有一些情况下,你可能希望防止不必要的更新。 | ||||||
得益于其响应性系统,Vue 总是知道何时更新 (如果你使用正确的话)。但是,在某些边缘情况下,你可能希望强制更新,尽管事实上没有任何响应式数据发生更改。还有一些情况下,你可能希望防止不必要的更新。 | ||||||
|
||||||
### 强制更新 | ||||||
|
||||||
如果你发现自己需要在 Vue 中强制更新,在 99.99%的情况下,你在某个地方犯了错误。例如,你可能依赖于 Vue 反应性系统未跟踪的状态,例如,在组件创建之后添加了 `data` 属性。 | ||||||
如果你发现自己需要在 Vue 中强制更新,在 99.99%的情况下,你在某个地方犯了错误。例如,你可能依赖于 Vue 响应性系统未跟踪的状态,例如,在组件创建之后添加了 `data` 属性。 | ||||||
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
减少重复 |
||||||
|
||||||
但是,如果你已经排除了上述情况,并且发现自己处于这种非常罕见的情况下,必须手动强制更新,那么你可以使用 [`$forceUpdate`](../api/instance-methods.html#forceupdate)。 | ||||||
|
||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,7 +127,7 @@ setup (props) { | |||||
} | ||||||
``` | ||||||
|
||||||
这是我们的出发点,但它还不能工作,因为我们的 `repositories` 变量不是被动的。这意味着从用户的角度来看,仓库列表将保持为空。我们来解决这个问题! | ||||||
这是我们的出发点,但它还不能工作,因为我们的 `repositories` 变量是非响应式的。这意味着从用户的角度来看,仓库列表将保持为空。我们来解决这个问题! | ||||||
|
||||||
### 带 `ref` 的响应式变量 | ||||||
|
||||||
|
@@ -317,13 +317,13 @@ setup (props) { | |||||
|
||||||
const repositories = ref([]) | ||||||
const getUserRepositories = async () => { | ||||||
// 更新`prop.user ` 到 `user.value`访问引用值 | ||||||
// 更新 `prop.user` 到 `user.value` 访问引用值 | ||||||
repositories.value = await fetchUserRepositories(user.value) | ||||||
} | ||||||
|
||||||
onMounted(getUserRepositories) | ||||||
|
||||||
// 在用户prop的响应式引用上设置一个侦听器 | ||||||
// 在用户 prop 的响应式引用上设置一个侦听器 | ||||||
watch(user, getUserRepositories) | ||||||
|
||||||
return { | ||||||
|
@@ -363,18 +363,18 @@ import { ref, onMounted, watch, toRefs, computed } from 'vue' | |||||
|
||||||
// in our component | ||||||
setup (props) { | ||||||
// 使用 `toRefs` 创建对props的 `user` property 的响应式引用 | ||||||
// 使用 `toRefs` 创建对 props 的 `user` property 的响应式引用 | ||||||
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
|
||||||
const { user } = toRefs(props) | ||||||
|
||||||
const repositories = ref([]) | ||||||
const getUserRepositories = async () => { | ||||||
// 更新`props.user ` 到 `user.value`访问引用值 | ||||||
// 更新 `props.user ` 到 `user.value` 访问引用值 | ||||||
repositories.value = await fetchUserRepositories(user.value) | ||||||
} | ||||||
|
||||||
onMounted(getUserRepositories) | ||||||
|
||||||
// 在用户prop的响应式引用上设置一个侦听器 | ||||||
// 在用户 prop 的响应式引用上设置一个侦听器 | ||||||
watch(user, getUserRepositories) | ||||||
|
||||||
const searchQuery = ref('') | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1343,7 +1343,7 @@ computed: { | |
5. **组合 API** (使用组合 API 的入口点) | ||
- `setup` | ||
|
||
6. **Local State** (本地的响应式 property) | ||
6. **Local State** (原生响应式 property) | ||
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. 这个应该是本地的吧 |
||
- `data` | ||
- `computed` | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
这里漏了一个“代理”没处理。另外关于 proxy 的翻译,这里也讨论一下:https://github.com/orgs/vuejs/teams/docs-cn/discussions/12
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.
“代理”的问题需要抽取出来单独处理,我会在下一个 PR 中,修复以下 suggested change