Skip to content

Commit b06be56

Browse files
committed
Merge branch '2.0' into 2.0-cn
# Conflicts: # src/guide/computed.md # src/guide/index.md # src/guide/installation.md # src/guide/instance.md # src/guide/render-function.md # src/guide/syntax.md # src/guide/transitions.md
2 parents 9a5eb82 + 63e0269 commit b06be56

17 files changed

+4870
-4466
lines changed

assets/lifecycle.ai

Lines changed: 4437 additions & 4399 deletions
Large diffs are not rendered by default.

src/api/index.md

Lines changed: 322 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@ type: api
378378

379379
### propsData
380380

381-
> 1.0.22+
382-
383381
- **Type:** `Object`
384382

385383
- **Restriction:** only respected in instance creation via `new`.
@@ -440,7 +438,6 @@ type: api
440438

441439
- **See also:**
442440
- [Computed Properties](/guide/computed.html)
443-
- [Reactivity in Depth: Inside Computed Properties](/guide/reactivity.html#Inside-Computed-Properties)
444441

445442
### methods
446443

@@ -500,6 +497,325 @@ type: api
500497

501498
- **See also:** [Instance Methods - vm.$watch](#vm-watch)
502499

500+
## Options / DOM
501+
502+
### el
503+
504+
- **Type:** `String | HTMLElement | Function`
505+
506+
- **Restriction:** only accepts type `Function` when used in a component definition.
507+
508+
- **Details:**
509+
510+
Provide the Vue instance an existing DOM element to mount on. It can be a CSS selector string, an actual HTMLElement, or a function that returns an HTMLElement. Note that the provided element merely serves as a mounting point; it will be replaced if a template is also provided. The resolved element will be accessible as `vm.$el`.
511+
512+
When used in `Vue.extend`, a function must be provided so each instance gets a separately created element.
513+
514+
If this option is available at instantiation, the instance will immediately enter compilation; otherwise, the user will have to explicitly call `vm.$mount()` to manually start the compilation.
515+
516+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
517+
518+
### template
519+
520+
- **Type:** `String`
521+
522+
- **Details:**
523+
524+
A string template to be used as the markup for the Vue instance. The template will **replace** the mounted element. Any existing markup inside the mounted element will be ignored, unless content distribution slots are present in the template.
525+
526+
If the string starts with `#` it will be used as a querySelector and use the selected element's innerHTML as the template string. This allows the use of the common `<script type="x-template">` trick to include templates.
527+
528+
- **See also:**
529+
- [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
530+
- [Content Distribution](/guide/components.html#Content-Distribution-with-Slots)
531+
- [Fragment Instance](/guide/components.html#Fragment-Instance)
532+
533+
### render
534+
535+
- **Type:** `Function`
536+
537+
- **Details:**
538+
539+
An alternative to string templates allowing you to leverage the full programmatic power of JavaScript. The render function receives a `createElement` method as it's first argument used to create `VNode`s.
540+
541+
- **See also:**
542+
- [Render Functions](/guide/render-function)
543+
544+
## Options / Lifecycle Hooks
545+
546+
### beforeCreate
547+
548+
- **Type:** `Function`
549+
550+
- **Details:**
551+
552+
Called synchronously after the instance has just been initialized, before data observation and event/watcher setup.
553+
554+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
555+
556+
### created
557+
558+
- **Type:** `Function`
559+
560+
- **Details:**
561+
562+
Called synchronously after the instance is created. At this stage, the instance has finished processing the options which means the following have been set up: data observation, computed properties, methods, watch/event callbacks. However, DOM compilation has not been started, and the `$el` property will not be available yet.
563+
564+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
565+
566+
### beforeMount
567+
568+
- **Type:** `Function`
569+
570+
- **Details:**
571+
572+
Called after the template has just been compiled, before `vm.$el` is created.
573+
574+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
575+
576+
### mounted
577+
578+
- **Type:** `Function`
579+
580+
- **Details:**
581+
582+
Called after the instance has just been mounted where `el` is replaced by the newly created `vm.$el`.
583+
584+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
585+
586+
### beforeUpdate
587+
588+
- **Type:** `Function`
589+
590+
- **Details:**
591+
592+
Called when the data changes, before the virtual DOM is re-rendered and patched.
593+
594+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
595+
596+
### updated
597+
598+
- **Type:** `Function`
599+
600+
- **Details:**
601+
602+
Called after a data change causes the virtual DOM to be re-rendered and patched.
603+
604+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
605+
606+
### activated
607+
608+
- **Type:** `Function`
609+
610+
- **Details:**
611+
612+
Called after a dynamic component is activated, allowing you to perform any necessary asynchronous operations before it should be swapped in.
613+
614+
The `activated` hook is only respected during dynamic component swapping or the initial render for static components - it does not affect manual insertions with instance methods.
615+
616+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
617+
618+
### deactivated
619+
620+
- **Type:** `Function`
621+
622+
- **Details:**
623+
624+
Called after the dynamic component has been swapped out.
625+
626+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
627+
628+
### beforeDestroy
629+
630+
- **Type:** `Function`
631+
632+
- **Details:**
633+
634+
Called right before a Vue instance is destroyed. At this stage the instance is still fully functional.
635+
636+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
637+
638+
### destroyed
639+
640+
- **Type:** `Function`
641+
642+
- **Details:**
643+
644+
Called after a Vue instance has been destroyed. When this hook is called, all bindings and directives of the Vue instance have been unbound and all child Vue instances have also been destroyed.
645+
646+
Note if there is a leaving transition, the `destroyed` hook is called **after** the transition has finished.
647+
648+
- **See also:** [Lifecycle Diagram](/guide/instance.html#Lifecycle-Diagram)
649+
650+
## Options / Assets
651+
652+
### directives
653+
654+
- **Type:** `Object`
655+
656+
- **Details:**
657+
658+
A hash of directives to be made available to the Vue instance.
659+
660+
- **See also:**
661+
- [Custom Directives](/guide/custom-directive.html)
662+
- [Assets Naming Convention](/guide/components.html#Assets-Naming-Convention)
663+
664+
### filters
665+
666+
- **Type:** `Object`
667+
668+
- **Details:**
669+
670+
A hash of filters to be made available to the Vue instance.
671+
672+
- **See also:**
673+
- [Custom Filters](/guide/custom-filter.html)
674+
- [Assets Naming Convention](/guide/components.html#Assets-Naming-Convention)
675+
676+
### components
677+
678+
- **Type:** `Object`
679+
680+
- **Details:**
681+
682+
A hash of components to be made available to the Vue instance.
683+
684+
- **See also:**
685+
- [Components](/guide/components.html)
686+
687+
### transitions
688+
689+
- **Type:** `Object`
690+
691+
- **Details:**
692+
693+
A hash of transitions to be made available to the Vue instance.
694+
695+
- **See also:**
696+
- [Transitions](/guide/transitions.html)
697+
698+
## Options / Misc
699+
700+
### parent
701+
702+
- **Type:** `Vue instance`
703+
704+
- **Details:**
705+
706+
Specify the parent instance for the instance to be created. Establishes a parent-child relationship between the two. The parent will be accessible as `this.$parent` for the child, and the child will be pushed into the parent's `$children` array.
707+
708+
- **See also:** [Parent-Child Communication](/guide/components.html#Parent-Child-Communication)
709+
710+
### mixins
711+
712+
- **Type:** `Array`
713+
714+
- **Details:**
715+
716+
The `mixins` option accepts an array of mixin objects. These mixin objects can contain instance options just like normal instance objects, and they will be merged against the eventual options using the same option merging logic in `Vue.extend()`. e.g. If your mixin contains a created hook and the component itself also has one, both functions will be called.
717+
718+
Mixin hooks are called in the order they are provided, and called before the component's own hooks.
719+
720+
- **Example:**
721+
722+
``` js
723+
var mixin = {
724+
created: function () { console.log(1) }
725+
}
726+
var vm = new Vue({
727+
created: function () { console.log(2) },
728+
mixins: [mixin]
729+
})
730+
// -> 1
731+
// -> 2
732+
```
733+
734+
- **See also:** [Mixins](/guide/mixins.html)
735+
736+
### name
737+
738+
- **Type:** `String`
739+
740+
- **Restriction:** only respected when used in `Vue.extend()`.
741+
742+
- **Details:**
743+
744+
Allow the component to recursively invoke itself in its template. Note that when a component is registered globally with `Vue.component()`, the global ID is automatically set as its name.
745+
746+
Another benefit of specifying a `name` option is console inspection. When inspecting an extended Vue component in the console, the default constructor name is `VueComponent`, which isn't very informative. By passing in an optional `name` option to `Vue.extend()`, you will get a better inspection output so that you know which component you are looking at. The string will be camelized and used as the component's constructor name.
747+
748+
- **Example:**
749+
750+
``` js
751+
var Ctor = Vue.extend({
752+
name: 'stack-overflow',
753+
template:
754+
'<div>' +
755+
// recursively invoke self
756+
'<stack-overflow></stack-overflow>' +
757+
'</div>'
758+
})
759+
760+
// this will actually result in a max stack size exceeded
761+
// error, but let's assume it works...
762+
var vm = new Ctor()
763+
764+
console.log(vm) // -> StackOverflow {$el: null, ...}
765+
```
766+
767+
### extends
768+
769+
- **Type:** `Object | Function`
770+
771+
- **Details:**
772+
773+
Allows declaratively extending another component (could be either a plain options object or a constructor) without having to use `Vue.extend`. This is primarily intended to make it easier to extend between single file components.
774+
775+
This is similar to `mixins`, the difference being that the component's own options takes higher priority than the source component being extended.
776+
777+
- **Example:**
778+
779+
``` js
780+
var CompA = { ... }
781+
782+
// extend CompA without having to call Vue.extend on either
783+
var CompB = {
784+
extends: CompA,
785+
...
786+
}
787+
```
788+
789+
### delimiters
790+
791+
- **Type:** `Array<String>`
792+
793+
- **default:** `["{{", "}}"]`
794+
795+
- **Details:**
796+
797+
Change the plain text interpolation delimiters. This option is only available in the standalone build.
798+
799+
- **Example:**
800+
801+
``` js
802+
new Vue({
803+
delimiters: ['${', '}']
804+
})
805+
806+
// Delimiters changed to ES6 template string style
807+
```
808+
809+
### functional
810+
811+
- **Type:** `boolean`
812+
813+
- **Details:**
814+
815+
Causes a component to be stateless (no `data`) and instanceless (no `this` context). They are simply a `render` function that returns virtual nodes making them much cheaper to render.
816+
817+
- **See also:** [Functional Components](/guide/render-function.html#Functional-Components)
818+
503819
## Instance Properties
504820

505821
### vm.$data
@@ -833,9 +1149,9 @@ type: api
8331149
<h3 id="vm-forceUpdate">vm.$forceUpdate( )</h3>
8341150

8351151
- **Usage:**
836-
1152+
8371153
The Vue instance will be forced the re-render.
838-
1154+
8391155
<p class="tip">Note: This method have an influence on your application performance degradation. The excessive call is no recommended.</p>
8401156

8411157
<h3 id="vm-destroy">vm.$destroy( )</h3>
@@ -1072,7 +1388,7 @@ type: api
10721388

10731389
<!-- prop binding. "prop" must be declared in my-component. -->
10741390
<my-component :prop="someThing"></my-component>
1075-
1391+
10761392
<!-- XLink -->
10771393
<svg><a :xlink:special="foo"></a></svg>
10781394
```

src/examples/hackernews.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,32 @@ type: examples
44
order: 10
55
---
66

7-
> This is a HackerNews clone built upon HN's official Firebase API, and using Webpack + vue-loader for the build setup.
7+
> This is a HackerNews clone built upon HN's official Firebase API, Vue 2.0 + vue-router + vuex, with server-side rendering.
88
9+
{% raw %}
910
<div style="max-width:600px">
10-
<a href="http://vuejs.github.io/vue-hackernews" target="_blank"><img style="width:100%" src="/images/hn.png"></a>
11+
<a href="https://github.com/vuejs/vue-hackernews-2.0" target="_blank">
12+
<img style="width:100%" src="/images/hn.png">
13+
</a>
1114
</div>
15+
{% endraw %}
1216

13-
> [[Source](https://github.com/vuejs/vue-hackernews)]
17+
> [Live Demo](https://vue-hn.now.sh/)
18+
> Note: the demo may need some spin up time if nobody has accessed it for a certain period.
19+
>
20+
> [[Source](https://github.com/vuejs/vue-hackernews-2.0)]
21+
22+
## Features
23+
24+
- Server Side Rendering
25+
- Vue + vue-router + vuex working together
26+
- Server-side data pre-fetching
27+
- Client-side state & DOM hydration
28+
- Single-file Vue Components
29+
- Hot-reload in development
30+
- CSS extraction for production
31+
- Real-time List Updates with FLIP Animation
32+
33+
## Architecture Overview
34+
35+
<img width="973" alt="Hackernew clone architecture overview" src="/images/hn-architecture.png">

0 commit comments

Comments
 (0)