Skip to content

Commit 8d83284

Browse files
authored
Merge pull request volksbright#12 from vuejs/2.0
2.0
2 parents bf61cc8 + 9f6d40e commit 8d83284

File tree

16 files changed

+409
-70
lines changed

16 files changed

+409
-70
lines changed

src/api/index.md

+10-11
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ type: api
251251
var MyComponent = Vue.component('my-component')
252252
```
253253

254-
- **See also:** [Components](/guide/components.html).
254+
- **See also:** [Components](/guide/components.html)
255255

256256
<h3 id="Vue-use">Vue.use( plugin )</h3>
257257

@@ -262,7 +262,7 @@ type: api
262262

263263
Install a Vue.js plugin. If the plugin is an Object, it must expose an `install` method. If it is a function itself, it will be treated as the install method. The install method will be called with Vue as the argument.
264264

265-
- **See also:** [Plugins](/guide/plugins.html).
265+
- **See also:** [Plugins](/guide/plugins.html)
266266

267267
<h3 id="Vue-mixin">Vue.mixin( mixin )</h3>
268268

@@ -296,7 +296,7 @@ type: api
296296
})
297297
```
298298

299-
- **See also:** [Render Functions](/guide/render-function.html).
299+
- **See also:** [Render Functions](/guide/render-function.html)
300300

301301
## Options / Data
302302

@@ -338,7 +338,7 @@ type: api
338338
})
339339
```
340340

341-
- **See also:** [Reactivity in Depth](/guide/reactivity.html).
341+
- **See also:** [Reactivity in Depth](/guide/reactivity.html)
342342

343343
### props
344344

@@ -581,7 +581,7 @@ type: api
581581

582582
- **See also:**
583583
- [Child-Component-Reference](/guide/components.html#Child-Component-Reference)
584-
- !!TODO: [ref](#ref).
584+
- [ref](#ref)
585585

586586
### vm.$isServer
587587

@@ -593,8 +593,7 @@ type: api
593593

594594
Whether the current Vue instance is running on the server-side.
595595

596-
- **See also:**
597-
- !!TODO: [Server-Side Rendering](/guide/ssr.html).
596+
- **See also:** [Server-Side Rendering](/guide/ssr.html)
598597

599598
## Instance Methods / Data
600599

@@ -787,7 +786,7 @@ type: api
787786

788787
- **See also:**
789788
- [Vue.nextTick](#Vue-nextTick)
790-
-!!TODO: [Async Update Queue](/guide/reactivity.html#Async-Update-Queue)
789+
- [Async Update Queue](/guide/reactivity.html#Async-Update-Queue)
791790

792791
## Instance Methods / Lifecycle
793792

@@ -829,13 +828,13 @@ type: api
829828

830829
- **See also:**
831830
- [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
832-
- !!TODO: [Server-Side Rendering](/guide/ssr.html)
831+
- [Server-Side Rendering](/guide/ssr.html)
833832

834833
<h3 id="vm-forceUpdate">vm.$forceUpdate( )</h3>
835834

836835
- **Usage:**
837836

838-
The Vue instance will be forced into a “digest cycle”, during which all its watchers are re-evaluated.
837+
The Vue instance will be forced the re-render.
839838

840839
<p class="tip">Note: This method have an influence on your application performance degradation. The excessive call is no recommended.</p>
841840

@@ -875,7 +874,7 @@ type: api
875874

876875
- **Details:**
877876

878-
Updates the element's `innerHTML`. The contents are inserted as plain HTML - data bindings are ignored. If you need to reuse template pieces, you should use [functional components](!!TODO).
877+
Updates the element's `innerHTML`. The contents are inserted as plain HTML - data bindings are ignored. If you need to reuse template pieces, you should use [functional components](/guide/render-function.html#Functional-Components).
879878

880879
<p class="tip">Dynamically rendering arbitrary HTML on your website can be very dangerous because it can easily lead to [XSS attacks](https://en.wikipedia.org/wiki/Cross-site_scripting). Only use `v-html` on trusted content and **never** on user-provided content.</p>
881880

src/guide/class-and-style.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ We can pass an object to `v-bind:class` to dynamically toggle classes:
1818
``` js
1919
data: {
2020
isActive: true,
21-
hasEror: false
21+
hasError: false
2222
}
2323
```
2424

src/guide/comparison.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,30 @@ In every real-world scenario that we've tested so far, Vue outperforms React by
2626

2727
#### Render Performance
2828

29-
Here's a simplified way to think about it. In React, let's say the cost of rendering an element is 1 and the cost of an average component is 2. In Vue, the cost of an element would be more like 0.1, but the cost of an average component would be 4, due to the setup required for our reactivity system.
29+
When rendering UI, manipulating the DOM is typically the most expensive operation and unfortunately, no library can make those raw operations faster. The best we can do is:
3030

31-
In extreme cases, such as using 1 normal component to render each element, Vue will probably be slower. However, both Vue and React offer functional components that would typically be preferred in a situation like this. As of writing, React plans to offer performance improvements for functional components, making them roughly the cost of elements. Vue's functional components already offer that optimization, so that when using functional components, Vue should then perform about 20 times as fast in this scenario, but only 10 times as fast after React optimizes their functional components.
31+
1. Minimize the number of necessary DOM mutations. Both React and Vue use virtual DOM abstractions to accomplish this and both implementations work about equally well.
32+
2. Add as little overhead as possible on top of those DOM manipulations. This is an area where Vue and React differ.
33+
34+
In React, let's say the additional overhead of rendering an element is 1 and the overhead of an average component is 2. In Vue, the overhead of an element would be more like 0.1, but the overhead of an average component would be 4, due to the setup required for our reactivity system.
35+
36+
This means that in typical applications, where there are many more elements than components being rendered, Vue will outperform React by a significant margin. To demonstrate this, let's render a list of 10,000 items in a single component. In Chrome 52 on my 2014 Macbook Air, [Vue renders](https://jsfiddle.net/chrisvfritz/859gL422/) in an average of 60ms, while [React renders](https://jsfiddle.net/chrisvfritz/65ojbkab/) in an average of 127ms.
37+
38+
In extreme cases however, such as using 1 normal component to render each element, Vue will usually be slower. When modifying the previous examples accordingly, [Vue renders](https://jsfiddle.net/chrisvfritz/mk8jaqpg/) in ~585ms, while [React renders](https://jsfiddle.net/chrisvfritz/2sx0341o/) in ~157ms! This isn't the end of the story though. Both Vue and React offer functional components, which are preferred in situations like this. Since functional components are closer to the cost of elements, Vue is once again on top, with [~73ms](https://jsfiddle.net/chrisvfritz/413wjqyf/) vs [~144ms](https://jsfiddle.net/chrisvfritz/kss01xg7/) - and this performance boost only required adding a single line for Vue: `functional: true`.
3239

3340
#### Update Performance
3441

3542
In React, you need to implement `shouldComponentUpdate` everywhere and use immutable data structures to achieve fully optimized re-renders. In Vue, a component's dependencies are automatically tracked so that it only updates when one of those dependencies change. The only further optimization that sometimes can be helpful in Vue is adding a `key` attribute to items in long lists.
3643

37-
This means updates in unoptimized Vue will be much faster than unoptimized React and actually, due to the improved render performance in Vue, even optimized React will usually be slower than Vue is out-of-the-box.
44+
This means updates in unoptimized Vue will be much faster than unoptimized React and actually, due to the improved render performance in Vue, even fully-optimized React will usually be slower than Vue is out-of-the-box.
3845

3946
#### In Development
4047

41-
Obviously, performance in production is the most important and that's what we've been discussing so far. Performance in development still matters though. Both Vue and React remain fast enough in development for most normal applications.
48+
Obviously, performance in production is the most important and that's what we've been discussing so far. Performance in development still matters though. The good news is that both Vue and React remain fast enough in development for most normal applications.
4249

43-
However, if you're prototyping any high-performance data visualizations or animations, you may find it useful to know that in scenarios where Vue can't handle more than 20 frames per second in development, we've seen React slow down to 2 frames per second.
50+
However, if you're prototyping any high-performance data visualizations or animations, you may find it useful to know that in scenarios where Vue can't handle more than 10 frames per second in development, we've seen React slow down to about 1 frame per second.
4451

45-
This is due to React's many heavy invariant checks, which help it provide many excellent warnings and error messages. We agree that these are important in Vue, but have also kept an eye on performance while we implement these checks.
52+
This is due to React's many heavy invariant checks, which help it to provide many excellent warnings and error messages. We agree that these are important in Vue, but have tried to keep a closer eye on performance while we implement these checks.
4653

4754
### HTML & CSS
4855

@@ -140,7 +147,7 @@ For large applications, both Vue and React offer robust routing solutions. The R
140147

141148
Another important difference between these offerings is that Vue's companion libraries for state management and routing (among [other concerns](https://github.com/vuejs)) are all officially supported and kept up-to-date with the core library. React instead chooses to leave these concerns to the community, creating a more fragmented ecosystem.
142149

143-
Finally, Vue offers a [CLI project generator](https://github.com/vuejs/vue-cli) that makes it trivially easy to start a new project using your choice of build system, including [Webpack](github.com/vuejs-templates/webpack), [Browserify](github.com/vuejs-templates/browserify), or even [no build system](https://github.com/vuejs-templates/simple). React is also making strides in this area with [create-react-app](https://github.com/facebookincubator/create-react-app), but it currently has a few limitations:
150+
Finally, Vue offers a [CLI project generator](https://github.com/vuejs/vue-cli) that makes it trivially easy to start a new project using your choice of build system, including [Webpack](https://github.com/vuejs-templates/webpack), [Browserify](https://github.com/vuejs-templates/browserify), or even [no build system](https://github.com/vuejs-templates/simple). React is also making strides in this area with [create-react-app](https://github.com/facebookincubator/create-react-app), but it currently has a few limitations:
144151

145152
- It does not allow any configuration during project generation, while Vue's project templates allow Yeoman-like customization.
146153
- It only offers a single template that assumes you're building a single-page application, while Vue offers a wide variety of templates for various purposes and build systems.

src/guide/components.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ Let's see it in action:
640640
v-model="message"
641641
></my-input>
642642
</div>
643-
````
643+
```
644644

645645
``` js
646646
Vue.component('my-input', {
@@ -1103,9 +1103,9 @@ The factory function receives a `resolve` callback, which should be called when
11031103

11041104
``` js
11051105
Vue.component('async-webpack-example', function (resolve) {
1106-
// this special require syntax will instruct webpack to
1106+
// This special require syntax will instruct Webpack to
11071107
// automatically split your built code into bundles which
1108-
// are automatically loaded over ajax requests.
1108+
// are loaded over Ajax requests.
11091109
require(['./my-async-component'], resolve)
11101110
})
11111111
```

src/guide/forms.md

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ order: 10
88

99
You can use the `v-model` directive to create two-way data bindings on form input and textarea elements. It automatically picks the correct way to update the element based on the input type. Although a bit magical, `v-model` is essentially syntax sugar for updating data on user input events, plus special care for some edge cases.
1010

11+
<p class="tip">`v-model` doesn't care about the initial value provided to an input or a textarea. It will always treat the Vue instance data as the source of truth.</p>
12+
1113
### Text
1214

1315
``` html
@@ -55,6 +57,11 @@ new Vue({
5557
</script>
5658
{% endraw %}
5759

60+
61+
{% raw %}
62+
<p class="tip">Interpolation on textareas (<code>&lt;textarea&gt;{{text}}&lt;/textarea&gt;</code>) won't work. Use <code>v-model</code> instead.</p>
63+
{% endraw %}
64+
5865
### Checkbox
5966

6067
Single checkbox, boolean value:

src/guide/installation.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ Vue.js provides an [official CLI](https://github.com/vuejs/vue-cli) for quickly
5454
``` bash
5555
# install vue-cli
5656
$ npm install --global vue-cli
57-
# create a new project using the "webpack" boilerplate
58-
# !!TODO: THIS TEMPLATE DOES NOT EXIST YET
59-
$ vue init webpack-2.0 my-project
57+
# create a new project using the "webpack" template
58+
$ vue init webpack my-project
6059
# install dependencies and go!
6160
$ cd my-project
6261
$ npm install

0 commit comments

Comments
 (0)