Skip to content
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

translate: tutorial/data-method.md, working on #65 #79

Merged
merged 2 commits into from
Nov 19, 2018

Conversation

harttle
Copy link
Member

@harttle harttle commented Nov 1, 2018

No description provided.

@andycall andycall mentioned this pull request Nov 1, 2018
54 tasks

`说明`:为什么是通过 San 提供的方法操作数据,而不是直接操作数据?因为defineProperty并未被国内常用的浏览器广泛支持,并且我们也并不喜欢这种侵入式的风格,所以我们选择了折中的方式。因此,只有通过 San 提供的方法修改数据,视图才会自动刷新。
`Note`: You may ask why do we have to use these methods instead of manipulate data directly? That's because the [defineProperty](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty) API is still not fully supported by major browsers in China and we prefer non-invasive ways to implement data binding. As a result, you have to use the methods provided by San in order to get the views updated automatically.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of manipulate data directly -> manipulating

@@ -76,7 +76,7 @@ san.defineComponent({
});
```

`注意`: **get** 方法获取的数据不能直接修改,否则可能导致不一致的问题。数据修改请使用本文下面的 **set****splice** 等方法
`Note`: The data retrieved via **get** method is not expected to be modified, which will lead to an inconsistent state. Use the following **set**, **splice** methods to modify any data.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of manipulate data directly -> an应该不用


apply 方法接受一个函数作为参数,传入当前的值到函数,然后用新返回的值更新它。其行为类似 `Array.prototype.map` 方法。
`.apply()` method accepts a function argument, which takes the data's current value as its input, and returns the updated value. It's behavior is like the JavaScript `Array.prototype.map` method.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该强调类似的是“map中的callback函数”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原文中 “其行为” 指的是 .apply() 的行为吧,翻译中可以明确下

------

我们提供了一些数组操作的方法,这些方法与 JavaScript 的数组操作方法基本同名,以减少使用者的学习与记忆成本。除了 **删除** 操作。
We provide a number of methods for `Array` manipulation. All of them take the same name as the corresponding JavaScript `Array` methods except **remove**. Hope it helps to memorize!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array -> array,没必要标记为代码块

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corresponding JavaScript Array methods -> Array.prototype

@otakustay otakustay merged commit e73de59 into baidu:master Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants