Skip to content

Commit 6a2bd62

Browse files
committed
Merge branch 'master' of github.com:vuejs/vuejs.org
2 parents b3ec209 + 164cfcb commit 6a2bd62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+7876
-6547
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ db.json
44
*.log
55
node_modules/
66
public/
7-
.deploy*/
7+
.deploy*/
8+
source/_drafts

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
all: update
2-
rm -f db.json
32
hexo generate
4-
cp -R ../vue/test/unit public
53
cp -R ./todomvc public/examples
64

75
deploy: all
86
hexo deploy
97

108
update:
11-
cd ../vue && git checkout master && grunt build && grunt build-test
9+
cd ../vue && git checkout master && grunt build
1210
cp ../vue/dist/vue.min.js themes/vue/source/js/vue.min.js
1311
cp ../vue/dist/vue.js themes/vue/source/js/vue.js
14-
node update.js
12+
node update.js

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# vuejs.org
22

3-
This site is built with [hexo](http://zespia.tw/hexo/). Site content is written in Markdown format located in `source`. Pull requests welcome!
3+
This site is built with [hexo](http://hexo.io/). Site content is written in Markdown format located in `source`. Pull requests welcome!
44

55
## Developing
66

7-
Make sure you are using **hexo 3.0**. Start a dev server at `localhost:4000`:
7+
Start a dev server at `localhost:4000`:
88

99
```
1010
$ npm install -g hexo-cli

assets/icons.psd

-940 KB
Binary file not shown.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"version": "0.11.5",
44
"private": true,
55
"hexo": {
6-
"version": "3.0.0-rc.4"
6+
"version": "3.1.1"
77
},
88
"dependencies": {
9-
"hexo": "3.0.0-rc.4",
9+
"hexo": "3.1.1",
1010
"hexo-deployer-git": "0.0.3",
1111
"hexo-generator-archive": "^0.1.0",
1212
"hexo-generator-category": "^0.1.0",

source/_posts/011-component.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ date: 2014-12-08 15:02:14
33
tags:
44
---
55

6+
<p class="tip">Note: this post contains information for the outdated 0.11 version. Please refer to the [0.12 release notes](https://github.com/yyx990803/vue/releases) for the changes in the API.</p>
7+
68
The release of 0.11 introduced [many changes](https://github.com/yyx990803/vue/blob/master/changes.md), but the most important one is how the new component scope works. Previously in 0.10.x, components have inherited scope by default. That means in a child component template you can reference parent scope properties. This often leads to tightly-coupled components, where a child component assumes knowledge of what properties are present in the parent scope. It is also possible to accidentally refer to a parent scope property in a child component.
79

810
<!-- more -->
@@ -55,4 +57,4 @@ Previously the standard way for a child component to communicate to its parent i
5557

5658
The most common use case is for a parent to react to the events from a specific, direct child component. So in 0.11.4, [a new directive `v-events`](/api/directives.html#v-events) has been introduced to enable exactly this behavior.
5759

58-
0.11.4 has already been released, go try it out!
60+
0.11.4 has already been released, go try it out!

source/_posts/012-release.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
title: Vue.js 0.12 released!
2+
date: 2015-06-11 17:37:30
3+
---
4+
5+
I'm really excited to announce that [Vue.js 0.12: Dragon Ball](https://github.com/yyx990803/vue/releases/tag/0.12.0) is finally here! Thanks to everyone who tried out the beta/rc versions and provided feedback / bug reports along the way.
6+
7+
There's a lot to cover in this release, and we will talk about a few highlights below. However, it is still recommended to carefully go through the [Full Release Note](https://github.com/yyx990803/vue/releases/tag/0.12.0) and updated docs if you are upgrading from 0.11. You can report bugs on GitHub, send questions to [vuejs/Discussion](https://github.com/vuejs/Discussion/issues), or join us in the [Gitter chat channel](https://gitter.im/yyx990803/vue).
8+
9+
<!-- more -->
10+
11+
### More Consistent Component Syntax
12+
13+
Previously in 0.11 you have two ways to use a Vue.js component: using the `v-component` directive, or using custom elements. There are also two ways to pass data down to child components: using the `v-with` directive, or using the `paramAttributes` option. Although both custom elements and param attributes get compiled down to directives eventually, it is confusing and redundant to have two sets of syntax for the same functionality.
14+
15+
In addition, it should be noted that the component system is a first-class concept in Vue.js, even more important than directives. It defines how we encapsulate our higher-level view logic and compose our application. In the meanwhile, having a clear and declarative way to pass data into child components is also very important. Components and param attributes really deserve their own dedicated syntax to differentiate from other directives.
16+
17+
As a result, `v-component` and `v-with` have been deprecated in 0.12. `paramAttributes` has also been renamed to `props`, which is shorter and cleaner. From now on, most Vue.js components will look like this:
18+
19+
``` html
20+
<my-component prop="{{parentData}}"></my-component>
21+
```
22+
23+
There are also additional props-related improvements such as explicit one-time or one-way props, expression as props, methods as prop callbacks and more. You can find out more details in the 0.12 release notes linked above and the updated [Component System](/guide/components.html) section of the guide.
24+
25+
### Filter Arguments Improvements
26+
27+
In 0.11, filters always receive their arguments as plain strings. An argument can be enclosed in quotes to include whitespace, but the quotes are not automatically stripped when passed into the filter function. Some users were also confused about how to retrive a dynamic value on the vm instead of a plain string.
28+
29+
In 0.12, the filter argument syntax now follows a simple rule: if an argument is enclosed in quotes, it will be passed in as a plain string; otherwise, it will be evaluated against the current vm as a dynamic value.
30+
31+
This means the usage of some existing filters will have to change:
32+
33+
``` html
34+
<a v-on="keyup: onKeyUp | key 'enter'"></a>
35+
{{ items.length | pluralize 'item' }}
36+
```
37+
38+
But it would make custom filters that rely on dynamic values much easier to write:
39+
40+
``` html
41+
{{ msg | concat otherMsg }}
42+
```
43+
44+
Here the first argument to the `concat` filter will be the value of `this.otherMsg`.
45+
46+
### Asynchronous Components
47+
48+
It is common practice to bundle all the JavaScript into one file when building large single page applications. But when the file becomes too large, we may want to defer loading parts of our application for a faster initial load. However, this does pose some constraints on how the application architecture should be designed. It could be very tricky to figure out how to properly split up your JavaScript bundles.
49+
50+
Well, with Vue.js we can already build our applications as decoupled components. If we can lazily load a dynamic component only when it is needed, wouldn't it be awesome? As a matter of fact, in 0.12 this would be trivially easy with the new Asynchronous Component feature.
51+
52+
In 0.12, you can define a component as a factory function that asynchronously resolves a component definition (can be just a plain options object). Vue.js will only trigger the factory function when the component actually needs to be rendered, and will cache the result for future re-renders:
53+
54+
``` js
55+
Vue.component('async-example', function (resolve, reject) {
56+
setTimeout(function () {
57+
resolve({
58+
template: '<div>I am async!</div>'
59+
})
60+
}, 1000)
61+
})
62+
```
63+
64+
It is up to you to decide how to load the component from the server, e.g. `$.getScript()` or require.js; but the recommended usage is to pair it up with Webpack's [Code Splitting feature](http://webpack.github.io/docs/code-splitting.html):
65+
66+
``` js
67+
Vue.component('async-webpack-example', function (resolve, reject) {
68+
// In Webpack AMD like syntax indicates a code split point
69+
require(['./my-async-component'], resolve)
70+
})
71+
```
72+
73+
That's all you need to do. You can use the component just like before, without even thinking about it being async. Webpack will automatically split your final JavaScript into separate bundles with correct dependencies, and automatically load a bundle via Ajax when it is required. You can check out a fully functional example [here](https://github.com/vuejs/vue-webpack-example).
74+
75+
### Improved Transition System
76+
77+
Vue.js' transition system is really easy to use, but in the past it has the limitation that you cannot mix CSS and JavaScript-based transitions together. In 0.12 that is no longer the case! The improved transition system now allows you to add JavaScript hooks to a CSS-based transition for additional control. The amount of hooks exposed have also been expanded to give you finer-grained control at every stage of the transition.
78+
79+
`v-repeat` now also ships with built-in support for staggering transitions. It is as simple as adding `stagger="100"` to your repeated element. It is also possible to define separate staggering for enter and leaving, or even dynamically calculate the staggering delay in a JavaScript hook.
80+
81+
For full details on the new transition system, check out the [updated guide](/guide/transitions.html).
82+
83+
### Performance Tuning
84+
85+
Vue.js' precise dependency tracking makes it the one of the most efficient view layer for small hot updates, but there's always room for improvement. In 0.12, internal instance creation and compilation refactors have improved first-render performance for large lists by up to 40%. With proper `track-by` usage, [re-rendering with large, brand new dataset](http://vuejs.github.io/js-repaint-perfs/vue/) is also comparable to, or even faster other Virtual-DOM based frameworks.
86+
87+
### One More Thing...
88+
89+
With 0.12 out of the door, more efforts will now be spent on the official vue-router, a dedicated routing library for Vue.js with nested view matching, full transition support, and asynchronous data hooks. I have expressed that Vue.js core intends to stay as a no-frills, drop-in view layer library, and that will not change. The vue-router will be shipped separately and is totally optional, however you can expect it to work seamlessly with Vue.js core when you need it.

source/api/directives.md

Lines changed: 17 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ order: 6
1111

1212
Updates the element's `textContent`.
1313

14-
Internally, &#123;&#123; Mustache &#125;&#125; interpolations are also compiled as a `v-text` direcitve on a textNode.
14+
Internally, &#123;&#123; Mustache &#125;&#125; interpolations are also compiled as a `v-text` directive on a textNode.
1515

1616
### v-html
1717

@@ -41,6 +41,8 @@ If a directive argument is provided, the argument will be the class to be toggle
4141
"></span>
4242
```
4343

44+
Alternatively, you can bind the directive directly to an Object. The keys of the object will the list of classes to toggle based on corresponding values.
45+
4446
### v-attr
4547

4648
- This directive requires an argument.
@@ -53,6 +55,10 @@ Updates the element's given attribute (indicated by the argument).
5355
<canvas v-attr="width:w, height:h"></canvas>
5456
```
5557

58+
Falsy values except 0 will remove the attribute.
59+
60+
Alternatively, you can bind the directive directly to an Object. The keys of the object will the list of attributes to set based on corresponding values.
61+
5662
Internally, &#123;&#123; Mustache &#125;&#125; interpolations inside attributes are compiled into computed `v-attr` directives.
5763

5864
<p class="tip">You should use `v-attr` instead of mustache binding when setting the `src` attribute on `<img>` elements. Your templates are parsed by the browser before being compiled by Vue.js, so the mustache binding will cause a 404 when the browser tries to fetch it as the image's URL.</p>
@@ -117,7 +123,7 @@ Attaches an event listener to the element. The event type is denoted by the argu
117123
### v-model
118124

119125
- This directive can only be used on `<input>`, `<select>` or `<textarea>` elements.
120-
- Directive params: `lazy`, `number`, `options`
126+
- Directive params: [`lazy`](/guide/forms.html#Lazy_Updates), [`number`](/guide/forms.html#Casting_Value_as_Number), [`options`](/guide/forms.html#Dynamic_Select_Options), [`debounce`](/guide/forms.html#Input_Debounce)
121127

122128
Create a two-way binding on a form input element. Data is synced on every `input` event by default. For detailed examples see [Handling Forms](/guide/forms.html).
123129

@@ -151,7 +157,7 @@ Will render:
151157
- This directive requires the value to be an Array, Object or Number.
152158
- This directive can trigger transitions.
153159
- This directive accepts an optional argument.
154-
- Directive params: `trackby`
160+
- Directive params: [`track-by`](/guide/list.html#Using_track-by), [`stagger`](/guide/transitions.html#Staggering_Transitions), [`enter-stagger`](/guide/transitions.html#Staggering_Transitions), [`leave-stagger`](/guide/transitions.html#Staggering_Transitions)
155161

156162
Create a child ViewModel for every item in the binding Array or Object. If the value is a whole Number then that many child ViewModels are created. These child ViewModels will be automatically created / destroyed when mutating methods, e.g. `push()`, are called on the Array or Object, or the number is increased or decreased.
157163

@@ -179,100 +185,30 @@ If an argument is provided, a wrapper data object will always be created, using
179185

180186
For detailed examples, see [Displaying a List](/guide/list.html).
181187

182-
### v-with
183-
184-
- This directive can only be used with `v-component`.
185-
- This directive accepts only keypaths, no expressions.
186-
187-
Allows a child ViewModel to inherit data from the parents. You can either pass in an Object which will be used as the `data` option, or bind individual parent properties to the child with different keys. This directive must be used in combination with `v-component`.
188-
189-
Example inheriting an object:
190-
191-
``` js
192-
// parent data looks like this
193-
{
194-
user: {
195-
name: 'Foo Bar',
196-
email: 'foo@bar.com'
197-
}
198-
}
199-
```
200-
201-
``` html
202-
<my-component v-with="user">
203-
<!-- you can access properties without `user.` -->
204-
{{name}} {{email}}
205-
</my-component>
206-
```
207-
208-
Example inheriting individual properties (using the same data):
209-
210-
```
211-
<my-component v-with="myName: user.name, myEmail: user.email">
212-
<!-- you can access properties with the new keys -->
213-
{{myName}} {{myEmail}}
214-
</my-component>
215-
```
216-
217-
### v-events
218-
219-
- This directive can only be used with `v-component`.
220-
- This directive accepts only keypaths, no expressions.
221-
222-
Allows a parent instance to listen to events on a child instance. The difference from `v-on` is that `v-events` listens to Vue's component system events created via `vm.$emit()` rather than DOM events. This directive allows more decoupled parent-child communication without having to hard-code event listeners into the parent component. Note that it can only be used together with `v-component`, i.e. on the root element of a child component.
223-
224-
**Example:**
225-
226-
``` html
227-
<!-- inside parent template -->
228-
<div v-component="child" v-events="change: onChildChange"></div>
229-
```
230-
231-
When the child component calls `this.$emit('change', ...)`, the parent's `onChildChange` method will be invoked with additional arguments passed to `$emit()`.
232-
233188
## Literal Directives
234189

235190
> Literal directives treat their attribute value as a plain string; they do not attempt to bind themselves to anything. All they do is executing the `bind()` function with the string value once. Literal directives accept mustache expressions inside their value, but these expressions will be evaluated only once on first compile and do not react to data changes.
236191
237-
### v-component
192+
### v-transition
193+
194+
- Can be made reactive with mustaches
238195

239-
- Directive params: `keep-alive`, `wait-for`, `transition-mode`
196+
Notify Vue.js to apply transitions to this element. The transition classes are applied when certain transition-triggering directives modify the element, or when the Vue instance's DOM manipulation methods are called.
240197

241-
Compile this element as a child ViewModel with a registered component constructor. This can be used with `v-with` to inehrit data from the parent. For more details see [Component System](/guide/components.html).
198+
For details, see [the guide on transitions](/guide/transitions.html).
242199

243200
### v-ref
244201

245-
Register a reference to a child component on its parent for easier access. Only respected when used in combination with `v-component` or `v-repeat`. The component instance will be accessible on its parent's `$` object. For an example, see [child reference](/guide/components.html#Child_Reference).
202+
Register a reference to a child component on its parent for easier access. Only respected when used on a component or with `v-repeat`. The component instance will be accessible on its parent's `$` object. For an example, see [child reference](/guide/components.html#Child_Reference).
246203

247204
When used with `v-repeat`, the value will be an Array containing all the child Vue instances corresponding to the Array they are bound to.
248205

206+
New in 0.12: If the `v-repeat`'s source data is an Object, then `v-ref` will return an Object with instances matching each key in the Object.
207+
249208
### v-el
250209

251210
Register a reference to a DOM element on its owner Vue instance for easier access. e.g. `<div v-el="hi">` will be accessible as `vm.$$.hi`.
252211

253-
### v-partial
254-
255-
Replace the element's innerHTML with a registered partial. Partials can be registered with `Vue.partial()` or passed inside the `partials` option.
256-
257-
Using the mustache tag inside `v-partial` makes it reactive:
258-
259-
``` html
260-
<!-- content will change based on vm.partialId -->
261-
<div v-partial="{{partialId}}"></div>
262-
```
263-
264-
You can also use this syntax (which doesn't support reactivity):
265-
266-
``` html
267-
<div>{{> my-partial}}</div>
268-
```
269-
270-
### v-transition
271-
272-
Notify Vue.js to apply transitions to this element. The transition classes are applied when certain transition-triggering directives modify the element, or when the Vue instance's DOM manipulation methods are called.
273-
274-
For details, see [the guide on transitions](/guide/transitions.html).
275-
276212
## Empty Directives
277213

278214
> Empty directives do not require and will ignore their attribute value.

source/api/filters.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ Pluralizes the argument based on the filtered value. When there is exactly one a
3232
**Example:**
3333

3434
``` html
35-
{{count}} {{count | pluralize item}}
35+
{{count}} {{count | pluralize 'item'}}
3636
```
3737

3838
*1 => '1 item'*
3939
*2 => '2 items'*
4040

4141
``` html
42-
{{date}}{{date | pluralize st nd rd th}}
42+
{{date}}{{date | pluralize 'st' 'nd' 'rd' 'th'}}
4343
```
4444

4545
Will result in:
@@ -79,7 +79,7 @@ Wrap the handler so it only gets called when the keyCode matches the argument. Y
7979
**Example:**
8080

8181
``` html
82-
<input v-on="keyup:doSomething | key enter">
82+
<input v-on="keyup:doSomething | key 'enter'">
8383
```
8484

8585
`doSomething` will only be called when the Enter key is pressed.

0 commit comments

Comments
 (0)