Skip to content

Commit c809368

Browse files
committed
Merge branch 'master' into 2.0-cn
* master: suggest () as replacement for () when used with parent and a direct child, fixes #455 mention that handlebars syntax is intentionally limited, fixes #459 improve JSX introduction, fixes #464 # Conflicts: # src/guide/render-function.md
2 parents 50a9b9d + 6d6decb commit c809368

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/guide/comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ That said, it would probably make a better comparison between Vue core and Ember
294294

295295
- Vue provides unobtrusive reactivity on plain JavaScript objects and fully automatic computed properties. In Ember, you need to wrap everything in Ember Objects and manually declare dependencies for computed properties.
296296

297-
- Vue's template syntax harnesses the full power of JavaScript expressions, while Handlebars' expression and helper syntax is quite limited in comparison.
297+
- Vue's template syntax harnesses the full power of JavaScript expressions, while Handlebars' expression and helper syntax is intentionally quite limited in comparison.
298298

299299
- Performance-wise, Vue outperforms Ember by a fair margin, even after the latest Glimmer engine update in Ember 2.0. Vue automatically batches updates, while in Ember you need to manually manage run loops in performance-critical situations.
300300

src/guide/migration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,9 @@ Vue.config.keyCodes.f1 = 112
750750

751751
The problem is event flows that depend on a component's tree structure can be hard to reason about and very brittle when the tree becomes large. It simply doesn't scale well and we don't want to set you up for pain later. `$dispatch` and `$broadcast` also do not solve communication between sibling components.
752752

753-
For the simplest possible upgrade from `$dispatch` and `$broadcast`, you can use a centralized event hub that allows components to communicate no matter where they are in the component tree. Because Vue instances implement an event emitter interface, you can actually use an empty Vue instance for this purpose.
753+
One of the most common uses for these methods is to communicate between a parent and its direct children. In these cases, you can actually [listen to an `$emit` from a child with `v-on`](http://vuejs.org/guide/components.html#Form-Input-Components-using-Custom-Events). This allows you to keep the convenience of events with added explicitness.
754+
755+
However, when communicating between distant descendants/ancestors, `$emit` won't help you. Instead, the simplest possible upgrade would be to use a centralized event hub. This has the added benefit of allowing you to communicate between components no matter where they are in the component tree - even between siblings! Because Vue instances implement an event emitter interface, you can actually use an empty Vue instance for this purpose.
754756

755757
For example, let's say we have a todo app structured like this:
756758

src/guide/render-function.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,22 @@ render: function (createElement) {
264264

265265
## JSX
266266

267-
如果你写了很多 `render` 函数,可能会觉得痛苦,在多于 14 行代码的场景中还是模板简单、易读很多。
267+
如果你写了很多 `render` 函数,可能会觉得痛苦:
268+
269+
``` js
270+
createElement(
271+
'anchored-heading', {
272+
props: {
273+
level: 1
274+
}
275+
}, [
276+
createElement('span', 'Hello'),
277+
' world!'
278+
]
279+
)
280+
```
281+
282+
特别是模板如此简单的情况下:
268283

269284
``` html
270285
<anchored-heading :level="1">

0 commit comments

Comments
 (0)