You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an `Unknown custom element`, assuming that you forgot to register a global component or misspelled a component name.
97
+
82
98
### keyCodes
83
99
84
100
-**Type:**`{ [key: string]: number }`
@@ -249,7 +265,7 @@ type: api
249
265
250
266
-**Usage:**
251
267
252
-
Register or retrieve a global component.
268
+
Register or retrieve a global component. Registration also automatically sets the component's `name` with the given `id`.
253
269
254
270
```js
255
271
// register an extended constructor
@@ -813,7 +829,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
813
829
814
830
-**Type:**`Array<string>`
815
831
816
-
-**default:**`["{{", "}}"]`
832
+
-**default:**`{% raw %}["{{", "}}"]{% endraw %}`
817
833
818
834
-**Details:**
819
835
@@ -1508,7 +1524,7 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
1508
1524
1509
1525
-**Does not expect expression**
1510
1526
1511
-
-**Usage**
1527
+
-**Usage:**
1512
1528
1513
1529
Skip compilation for this element and all its children. You can use this for displaying raw mustache tags. Skipping large numbers of nodes with no directives on them can also speed up compilation.
Copy file name to clipboardExpand all lines: src/examples/todomvc.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6,4 +6,6 @@ order: 9
6
6
7
7
> This is a fully spec-compliant TodoMVC implementation in under 120 effective lines of JavaScript (excluding comments and blank lines).
8
8
9
+
<pclass="tip">Note that if your web browser is configured to block 3rd-party data/cookies, the example below will not work, as the `localStorage` data will fail to be saved from JSFiddle. You'll have to click on `Edit in JSFiddle` to see the live result.</p>
Copy file name to clipboardExpand all lines: src/guide/comparison.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -324,6 +324,6 @@ Riot 2.0 provides a similar component-based development model (which is called a
324
324
325
325
- True conditional rendering. Riot renders all if branches and simply shows/hides them.
326
326
- A far more powerful router. Riot’s routing API is extremely minimal.
327
-
- More mature tooling support. Vue provides official support for [Webpack](https://github.com/vuejs/vue-loader), [Browserify](https://github.com/vuejs/vueify), and [SystemJS](https://github.com/vuejs/systemjs-plugin-vue), while Riot relies on community support for build system integration.
327
+
- More mature tooling support. Vue provides official support for [Webpack](https://github.com/vuejs/vue-loader)and [Browserify](https://github.com/vuejs/vueify), while Riot relies on community support for build system integration.
328
328
-[Transition effect system](transitions.html). Riot has none.
329
329
- Better performance. [Despite advertising](https://github.com/vuejs/vuejs.org/issues/346) use of a virtual DOM, Riot in fact uses dirty checking and thus suffers from the same performance issues as Angular 1.
Copy file name to clipboardExpand all lines: src/guide/components.md
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -419,15 +419,17 @@ When a prop validation fails, Vue will produce a console warning (if using the d
419
419
420
420
## Custom Events
421
421
422
-
We have learned that the parent can pass data down to the child using props, but how do we communicate back to the parent when something happens? This is where custom events come in.
422
+
We have learned that the parent can pass data down to the child using props, but how do we communicate back to the parent when something happens? This is where Vue's custom event system comes in.
423
423
424
424
### Using `v-on` with Custom Events
425
425
426
-
Every Vue instance implements the [Events interface](/api/#Instance-Methods-Events), which means it can:
426
+
Every Vue instance implements an [events interface](/api/#Instance-Methods-Events), which means it can:
427
427
428
428
- Listen to an event using `$on(eventName)`
429
429
- Trigger an event using `$emit(eventName)`
430
430
431
+
<pclass="tip">Note that Vue's event system is separate from the browser's [EventTarget API](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). Though they work similarly, `$on` and `$emit` are __not__ aliases for `addEventListener` and `dispatchEvent`.</p>
432
+
431
433
In addition, a parent component can listen to the events emitted from a child component using `v-on` directly in the template where the child component is used.
432
434
433
435
Here's an example:
@@ -981,12 +983,26 @@ Again, this _only_ works within string templates, as self-closing custom element
981
983
982
984
Components can recursively invoke themselves in their own template. However, they can only do so with the `name` option:
983
985
986
+
```js
987
+
name:'unique-name-of-my-component'
988
+
```
989
+
990
+
When you register a component globally using `Vue.component`, the global ID is automatically set as the component's `name` option.
991
+
992
+
```js
993
+
Vue.component('unique-name-of-my-component', {
994
+
// ...
995
+
})
996
+
```
997
+
998
+
If you're not careful, recursive components can also lead to infinite loops:
A component like the above will result in a "max stack size exceeded" error, so make sure recursive invocation is conditional (i.e. uses a `v-if` that will eventually be false). When you register a component globally using `Vue.component`, the global ID is automatically set as the component's `name` option.
1005
+
A component like the above will result in a "max stack size exceeded" error, so make sure recursive invocation is conditional (i.e. uses a `v-if` that will eventually be `false`).
Copy file name to clipboardExpand all lines: src/guide/installation.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ vue_version: 2.0.3
6
6
dev_size: "188.88"
7
7
min_size: "62.54"
8
8
gz_size: "22.86"
9
+
ro_gz_size: "16"
9
10
---
10
11
11
12
### Compatibility Note
@@ -49,9 +50,9 @@ There are two builds available, the standalone build and the runtime-only build.
49
50
50
51
- The standalone build includes the compiler and supports the `template` option. **It also relies on the presence of browser APIs so you cannot use it for server-side rendering.**
51
52
52
-
- The runtime-only build does not include the template compiler, and does not support the `template` option. You can only use the `render` option when using the runtime-only build, but it works with single-file components, because single-file components' templates are pre-compiled into `render` functions during the build step. The runtime-only build is roughly 30% lighter-weight than the standalone build, weighing only 16kb min+gzip.
53
+
- The runtime-only build does not include the template compiler, and does not support the `template` option. You can only use the `render` option when using the runtime-only build, but it works with single-file components, because single-file components' templates are pre-compiled into `render` functions during the build step. The runtime-only build is roughly 30% lighter-weight than the standalone build, weighing only {{ro_gz_size}}kb min+gzip.
53
54
54
-
By default, the NPM package exports the **runtime-only** build. To use the standalone build, add the following alias to your webpack config:
55
+
By default, the NPM package exports the **runtime-only** build. To use the standalone build, add the following alias to your Webpack config:
Copy file name to clipboardExpand all lines: src/guide/migration-vue-router.md
+30-28Lines changed: 30 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ order: 26
8
8
9
9
## Router Initialization
10
10
11
-
### `router.start` <sup>deprecated</sup>
11
+
### `router.start` <sup>replaced</sup>
12
12
13
13
There is no longer a special API to initialize an app with Vue Router. That means instead of:
14
14
@@ -47,7 +47,7 @@ new Vue({
47
47
48
48
## Route Definitions
49
49
50
-
### `router.map` <sup>deprecated</sup>
50
+
### `router.map` <sup>replaced</sup>
51
51
52
52
Routes are now defined as an array on a [`routes` option](http://router.vuejs.org/en/essentials/getting-started.html#javascript) at router instantiation. So these routes for example:
53
53
@@ -82,7 +82,7 @@ The array syntax allows more predictable route matching, since iterating over an
82
82
</div>
83
83
{% endraw %}
84
84
85
-
### `router.on` <sup>deprecated</sup>
85
+
### `router.on` <sup>removed</sup>
86
86
87
87
If you need to programmatically generate routes when starting up your app, you can do so by dynamically pushing definitions to a routes array. For example:
88
88
@@ -128,7 +128,7 @@ router.match = createMatcher(
128
128
</div>
129
129
{% endraw %}
130
130
131
-
### `subRoutes` <sup>deprecated</sup>
131
+
### `subRoutes` <sup>renamed</sup>
132
132
133
133
[Renamed to `children`](http://router.vuejs.org/en/essentials/nested-routes.html) for consistency within Vue and with other routing libraries.
134
134
@@ -139,7 +139,7 @@ router.match = createMatcher(
139
139
</div>
140
140
{% endraw %}
141
141
142
-
### `router.redirect` <sup>deprecated</sup>
142
+
### `router.redirect` <sup>replaced</sup>
143
143
144
144
This is now an [option on route definitions](http://router.vuejs.org/en/essentials/redirect-and-alias.html). So for example, you will update:
145
145
@@ -165,7 +165,7 @@ to a definition like below in your `routes` configuration:
165
165
</div>
166
166
{% endraw %}
167
167
168
-
### `router.alias` <sup>deprecated</sup>
168
+
### `router.alias` <sup>replaced</sup>
169
169
170
170
This is now an [option on the definition for the route](http://router.vuejs.org/en/essentials/redirect-and-alias.html) you'd like to alias to. So for example, you will update:
Arbitrary route properties must now be scoped under the new meta property, to avoid conflicts with future features. So for example, if you had defined:
204
204
@@ -240,20 +240,20 @@ if (route.meta.requiresAuth) {
240
240
241
241
Route matching now uses [path-to-regexp](https://github.com/pillarjs/path-to-regexp) under the hood, making it much more flexible than previously.
242
242
243
-
### One or More Named Parameters
243
+
### One or More Named Parameters <sup>changed</sup>
244
244
245
245
The syntax has changed slightly, so `/category/*tags` for example, should be updated to `/category/:tags+`.
246
246
247
247
{% raw %}
248
248
<divclass="upgrade-path">
249
249
<h4>Upgrade Path</h4>
250
-
<p>Run the <ahref="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of the deprecated route syntax.</p>
250
+
<p>Run the <ahref="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of the obsolete route syntax.</p>
251
251
</div>
252
252
{% endraw %}
253
253
254
254
## Links
255
255
256
-
### `v-link` <sup>deprecated</sup>
256
+
### `v-link` <sup>replaced</sup>
257
257
258
258
The `v-link` directive has been replaced with a new [`<router-link>` component](http://router.vuejs.org/en/api/router-link.html), as this sort of job is now solely the responsibility of components in Vue 2. That means whenever wherever you have a link like this:
259
259
@@ -267,16 +267,18 @@ You'll need to update it like this:
267
267
<router-linkto="/about">About</router-link>
268
268
```
269
269
270
+
Note that `target="_blank"` is not supported on `<router-link>`, so if you need to open a link in a new tab, you have to use `<a>` instead.
271
+
270
272
{% raw %}
271
273
<divclass="upgrade-path">
272
274
<h4>Upgrade Path</h4>
273
275
<p>Run the <ahref="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of the <code>v-link</code> directive.</p>
274
276
</div>
275
277
{% endraw %}
276
278
277
-
### `v-link-active` <sup>deprecated</sup>
279
+
### `v-link-active` <sup>replaced</sup>
278
280
279
-
The `v-link-active` directive has also been deprecated in favor of specifying a separate tag on [the `<router-link>` component](http://router.vuejs.org/en/api/router-link.html). So for example, you'll update this:
281
+
The `v-link-active` directive has also been replaced by the `tag` attribute on [the `<router-link>` component](http://router.vuejs.org/en/api/router-link.html). So for example, you'll update this:
280
282
281
283
```html
282
284
<liv-link-active>
@@ -303,7 +305,7 @@ The `<a>` will be the actual link (and will get the correct href), but the activ
303
305
304
306
## Programmatic Navigation
305
307
306
-
### `router.go`
308
+
### `router.go` <sup>changed</sup>
307
309
308
310
For consistency with the [HTML5 History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API), `router.go` is now only used for [back/forward navigation](https://router.vuejs.org/en/essentials/navigation.html#routergon), while [`router.push`](http://router.vuejs.org/en/essentials/navigation.html#routerpushlocation) is used to navigate to a specific page.
309
311
@@ -316,7 +318,7 @@ For consistency with the [HTML5 History API](https://developer.mozilla.org/en-US
316
318
317
319
## Router Options: Modes
318
320
319
-
### `hashbang: false` <sup>deprecated</sup>
321
+
### `hashbang: false` <sup>removed</sup>
320
322
321
323
Hashbangs are no longer required for Google to crawl a URL, so they are no longer the default (or even an option) for the hash strategy.
322
324
@@ -327,7 +329,7 @@ Hashbangs are no longer required for Google to crawl a URL, so they are no longe
327
329
</div>
328
330
{% endraw %}
329
331
330
-
### `history: true` <sup>deprecated</sup>
332
+
### `history: true` <sup>replaced</sup>
331
333
332
334
All routing mode options have been condensed into a single [`mode` option](http://router.vuejs.org/en/api/options.html#mode). Update:
333
335
@@ -352,7 +354,7 @@ var router = new VueRouter({
352
354
</div>
353
355
{% endraw %}
354
356
355
-
### `abstract: true` <sup>deprecated</sup>
357
+
### `abstract: true` <sup>replaced</sup>
356
358
357
359
All routing mode options have been condensed into a single [`mode` option](http://router.vuejs.org/en/api/options.html#mode). Update:
358
360
@@ -379,7 +381,7 @@ var router = new VueRouter({
379
381
380
382
## Route Options: Misc
381
383
382
-
### `saveScrollPosition` <sup>deprecated</sup>
384
+
### `saveScrollPosition` <sup>replaced</sup>
383
385
384
386
This has been replaced with a [`scrollBehavior` option](http://router.vuejs.org/en/advanced/scroll-behavior.html) that accepts a function, so that the scroll behavior is completely customizable - even per route. This opens many new possibilities, but to simply replicate the old behavior of:
385
387
@@ -402,7 +404,7 @@ scrollBehavior: function (to, from, savedPosition) {
402
404
</div>
403
405
{% endraw %}
404
406
405
-
### `root` <sup>deprecated</sup>
407
+
### `root` <sup>renamed</sup>
406
408
407
409
Renamed to `base` for consistency with [the HTML `<base>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base).
408
410
@@ -413,7 +415,7 @@ Renamed to `base` for consistency with [the HTML `<base>` element](https://devel
413
415
</div>
414
416
{% endraw %}
415
417
416
-
### `transitionOnLoad` <sup>deprecated</sup>
418
+
### `transitionOnLoad` <sup>removed</sup>
417
419
418
420
This option is no longer necessary now that Vue's transition system has explicit [`appear` transition control](transitions.html#Transitions-on-Initial-Render).
419
421
@@ -424,7 +426,7 @@ This option is no longer necessary now that Vue's transition system has explicit
Removed due to hooks simplification. If you really must suppress transition errors, you can use [`try`...`catch`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) instead.
430
432
@@ -437,7 +439,7 @@ Removed due to hooks simplification. If you really must suppress transition erro
437
439
438
440
## Route Hooks
439
441
440
-
### `activate` <sup>deprecated</sup>
442
+
### `activate` <sup>replaced</sup>
441
443
442
444
Use [`beforeRouteEnter`](http://router.vuejs.org/en/advanced/navigation-guards.html#incomponent-guards) in the component instead.
443
445
@@ -448,7 +450,7 @@ Use [`beforeRouteEnter`](http://router.vuejs.org/en/advanced/navigation-guards.h
448
450
</div>
449
451
{% endraw %}
450
452
451
-
### `canActivate` <sup>deprecated</sup>
453
+
### `canActivate` <sup>replaced</sup>
452
454
453
455
Use [`beforeEnter`](http://router.vuejs.org/en/advanced/navigation-guards.html#perroute-guard) in the route instead.
454
456
@@ -459,7 +461,7 @@ Use [`beforeEnter`](http://router.vuejs.org/en/advanced/navigation-guards.html#p
459
461
</div>
460
462
{% endraw %}
461
463
462
-
### `deactivate` <sup>deprecated</sup>
464
+
### `deactivate` <sup>removed</sup>
463
465
464
466
Use the component's [`beforeDestroy`](/api/#beforeDestroy) or [`destroyed`](/api/#destroyed) hooks instead.
465
467
@@ -470,7 +472,7 @@ Use the component's [`beforeDestroy`](/api/#beforeDestroy) or [`destroyed`](/api
470
472
</div>
471
473
{% endraw %}
472
474
473
-
### `canDeactivate` <sup>deprecated</sup>
475
+
### `canDeactivate` <sup>replaced</sup>
474
476
475
477
Use [`beforeRouteLeave`](http://router.vuejs.org/en/advanced/navigation-guards.html#incomponent-guards) in the component instead.
476
478
@@ -481,7 +483,7 @@ Use [`beforeRouteLeave`](http://router.vuejs.org/en/advanced/navigation-guards.h
481
483
</div>
482
484
{% endraw %}
483
485
484
-
### `canReuse: false` <sup>deprecated</sup>
486
+
### `canReuse: false` <sup>removed</sup>
485
487
486
488
There's no longer a use case for this in the new Vue Router.
487
489
@@ -492,9 +494,9 @@ There's no longer a use case for this in the new Vue Router.
492
494
</div>
493
495
{% endraw %}
494
496
495
-
### `data` <sup>deprecated</sup>
497
+
### `data` <sup>replaced</sup>
496
498
497
-
The `$route` property is reactive, so you can just use a watcher to react to route changes, like this:
499
+
The `$route` property is now reactive, so you can just use a watcher to react to route changes, like this:
498
500
499
501
```js
500
502
watch: {
@@ -514,7 +516,7 @@ methods: {
514
516
</div>
515
517
{% endraw %}
516
518
517
-
### `$loadingRouteData` <sup>deprecated</sup>
519
+
### `$loadingRouteData` <sup>removed</sup>
518
520
519
521
Define your own property (e.g. `isLoading`), then update the loading state in a watcher on the route. For example, if fetching data with [axios](https://github.com/mzabriskie/axios):
0 commit comments