Skip to content

更新列表渲染数组更新检测的翻译 #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/v2/guide/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ example1.items = example1.items.filter(function (item) {
1. 当你利用索引直接设置一个项时,例如: `vm.items[indexOfItem] = newValue`
2. 当你修改数组的长度时,例如: `vm.items.length = newLength`

为了避免第一种情况,以下两种方式将达到像 `vm.items[indexOfItem] = newValue` 的效果, 同时也将触发状态更新:
为了解决第一类问题,以下两种方式都可以实现和 `vm.items[indexOfItem] = newValue` 相同的效果, 同时也将触发状态更新:

``` js
// Vue.set
Expand All @@ -393,7 +393,7 @@ Vue.set(example1.items, indexOfItem, newValue)
example1.items.splice(indexOfItem, 1, newValue)
```

避免第二种情况,使用 `splice`:
为了解决第二类问题,你也同样可以使用 `splice`:

``` js
example1.items.splice(newLength)
Expand Down