Skip to content

Commit 091d58a

Browse files
authored
Merge pull request #293 from vuejs/master
获取官方更新
2 parents 9c5fefe + 03a2fca commit 091d58a

File tree

14 files changed

+107
-22
lines changed

14 files changed

+107
-22
lines changed

src/support-vuejs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<img src="/images/actualize.png" style="width:180px">
3636
</a><a href="https://www.2mhost.com/" target="_blank">
3737
<img src="/images/2mhost.png">
38-
</a><a href="https://vuejsjob.com/?ref=vuejs" target="_blank" style="position:relative;top:6px">
38+
</a><a href="https://vuejobs.com/?ref=vuejs" target="_blank" style="position:relative;top:6px">
3939
<img src="/images/vuejobs.png">
4040
</a>
4141
</p>

src/v2/api/index.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type: api
9797

9898
### keyCodes
9999

100-
- **Type:** `{ [key: string]: number }`
100+
- **Type:** `{ [key: string]: number | Array<number> }`
101101

102102
- **Default:** `{}`
103103

@@ -107,7 +107,8 @@ type: api
107107
Vue.config.keyCodes = {
108108
v: 86,
109109
f1: 112,
110-
mediaPlayPause: 179
110+
mediaPlayPause: 179,
111+
up: [38, 87]
111112
}
112113
```
113114

@@ -965,8 +966,8 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
965966
var body = this.$slots.default
966967
var footer = this.$slots.footer
967968
return createElement('div', [
968-
createElement('header', header)
969-
createElement('main', body)
969+
createElement('header', header),
970+
createElement('main', body),
970971
createElement('footer', footer)
971972
])
972973
}
@@ -1518,6 +1519,9 @@ All lifecycle hooks automatically have their `this` context bound to the instanc
15181519

15191520
<!-- shorthand -->
15201521
<img :src="imageSrc">
1522+
1523+
<!-- with inline string concatenation -->
1524+
<img :src="'/path/to/images/' + fileName">
15211525

15221526
<!-- class binding -->
15231527
<div :class="{ red: isRed }"></div>

src/v2/guide/comparison.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ In React, everything is Just JavaScript, which sounds very simple and elegant -
101101

102102
#### JSX vs Templates
103103

104-
In React, all components express their UI within render functions using JSX, a declarative XML-like syntax that works within Javascript. Here's an example, [vetted by the React community](https://github.com/vuejs/vuejs.org/issues/364#issuecomment-244582684):
104+
In React, all components express their UI within render functions using JSX, a declarative XML-like syntax that works within JavaScript. Here's an example, [vetted by the React community](https://github.com/vuejs/vuejs.org/issues/364#issuecomment-244582684):
105105

106106
``` jsx
107107
render () {
@@ -267,7 +267,7 @@ We have a separate section for Angular 2 because it really is a completely new f
267267

268268
While Angular 1 could be used for smaller applications, Angular 2 has shifted focus to best facilitate large enterprise applications. As part of this, it almost requires TypeScript, which can be very useful for developers that desire the type safety of languages such as Java and C#.
269269

270-
Vue is also well-suited to [enterprise environments](https://github.com/vuejs/awesome-vue#enterprise-usage) and can even be used with TypeScript via our [official typings](https://github.com/vuejs/vue/tree/dev/types) and [user-contributed decorators](https://github.com/itsFrank/vue-typescript), though it's definitely optional in our case.
270+
Vue is also well-suited to [enterprise environments](https://github.com/vuejs/awesome-vue#enterprise-usage) and can even be used with TypeScript via our [official typings](https://github.com/vuejs/vue/tree/dev/types) and [official decorator](https://github.com/vuejs/vue-class-component), though it's definitely optional in our case.
271271

272272
### Size and Performance
273273

@@ -289,7 +289,7 @@ Angular 2's learning curve is much steeper. Even without TypeScript, their [Quic
289289

290290
Ember is a full-featured framework that is designed to be highly opinionated. It provides a lot of established conventions and once you are familiar enough with them, it can make you very productive. However, it also means the learning curve is high and flexibility suffers. It's a trade-off when you try to pick between an opinionated framework and a library with a loosely coupled set of tools that work together. The latter gives you more freedom but also requires you to make more architectural decisions.
291291

292-
That said, it would probably make a better comparison between Vue core and Ember's [templating](https://guides.emberjs.com/v2.7.0/templates/handlebars-basics/) and [object model](https://guides.emberjs.com/v2.7.0/object-model/) layers:
292+
That said, it would probably make a better comparison between Vue core and Ember's [templating](https://guides.emberjs.com/v2.10.0/templates/handlebars-basics/) and [object model](https://guides.emberjs.com/v2.10.0/object-model/) layers:
293293

294294
- 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.
295295

@@ -321,8 +321,7 @@ It is also totally feasible to offer deeper integration between Vue with Web Com
321321

322322
Riot 2.0 provides a similar component-based development model (which is called a "tag" in Riot), with a minimal and beautifully designed API. Riot and Vue probably share a lot in design philosophies. However, despite being a bit heavier than Riot, Vue does offer some significant advantages:
323323

324-
- True conditional rendering. Riot renders all if branches and simply shows/hides them.
324+
- [Transition effect system](transitions.html). Riot has none.
325325
- A far more powerful router. Riot’s routing API is extremely minimal.
326+
- Better performance. Riot [traverses a DOM tree](http://riotjs.com/compare/#virtual-dom-vs-expressions-binding) rather than using a virtual DOM, so suffers from the same performance issues as Angular 1.
326327
- 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.
327-
- [Transition effect system](transitions.html). Riot has none.
328-
- 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.

src/v2/guide/events.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ To address this problem, Vue provides **event modifiers** for `v-on`. Recall tha
164164
- `.prevent`
165165
- `.capture`
166166
- `.self`
167+
- `.once`
167168

168169
``` html
169170
<!-- the click event's propagation will be stopped -->
@@ -186,6 +187,15 @@ To address this problem, Vue provides **event modifiers** for `v-on`. Recall tha
186187
<div v-on:click.self="doThat">...</div>
187188
```
188189

190+
> New in 2.1.4
191+
192+
``` html
193+
<!-- the click event will be triggered at most once -->
194+
<a v-on:click.once="doThis"></a>
195+
```
196+
197+
Unlike the other modifiers, which are exclusive to native DOM events, the `.once` modifier can also be used on [component events](components.html#Using-v-on-with-Custom-Events). If you haven't read about components yet, don't worry about this for now.
198+
189199
## Key Modifiers
190200

191201
When listening for keyboard events, we often need to check for common key codes. Vue also allows adding key modifiers for `v-on` when listening for key events:

src/v2/guide/join.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Now we'll answer both what the community can do for and what you can do for the
1212

1313
### Get Support
1414

15-
- [Forum](http://forum.vuejs.org/): THE best place to ask questions and get answers about Vue and its ecosystem.
15+
- [Forum](http://forum.vuejs.org/): The best place to ask questions and get answers about Vue and its ecosystem.
1616
- [Gitter Channel](https://gitter.im/vuejs/vue): A place for devs to meet and chat. You can ask questions here too, but the forum is the better platform, since the discussions are threaded.
1717
- [Github](https://github.com/vuejs): If you have a bug to report or feature to request, that's what the GitHub issues are for. We also welcome pull requests!
1818

src/v2/guide/render-function.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ render: function (createElement) {
296296
value: self.value
297297
},
298298
on: {
299-
input: function (e) {
300-
self.value = e.target.value
299+
input: function (event) {
300+
self.value = event.target.value
301301
}
302302
}
303303
})
@@ -306,6 +306,57 @@ render: function (createElement) {
306306

307307
This is the cost of going lower-level, but it also gives you much more control over the interaction details compared to `v-model`.
308308

309+
### Event & Key Modifiers
310+
311+
For the `.capture` and `.once` event modifiers, Vue offers prefixes that can be used with `on`:
312+
313+
| Modifier(s) | Prefix |
314+
| ------ | ------ |
315+
| `.capture` | `!` |
316+
| `.once` | `~` |
317+
| `.capture.once` or<br>`.once.capture` | `~!` |
318+
319+
For example:
320+
321+
```javascript
322+
on: {
323+
'!click': this.doThisInCapturingMode,
324+
'~keyup': this.doThisOnce,
325+
`~!mouseover`: this.doThisOnceInCapturingMode
326+
}
327+
```
328+
329+
For all other event and key modifiers, no proprietary prefix is necessary, because you can simply use event methods in the handler:
330+
331+
| Modifier(s) | Equivalent in Handler |
332+
| ------ | ------ |
333+
| `.stop` | `event.stopPropagation()` |
334+
| `.prevent` | `event.preventDefault()` |
335+
| `.self` | `if (event.target !== event.currentTarget) return` |
336+
| Keys:<br>`.enter`, `.13` | `if (event.keyCode !== 13) return` (change `13` to [another key code](http://keycode.info/) for other key modifiers) |
337+
| Modifiers Keys:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return` (change `ctrlKey` to `altKey`, `shiftKey`, or `metaKey`, respectively) |
338+
339+
Here's an example with all of these modifiers used together:
340+
341+
```javascript
342+
on: {
343+
keyup: function (event) {
344+
// Abort if the element emitting the event is not
345+
// the element the event is bound to
346+
if (event.target !== event.currentTarget) return
347+
// Abort if the key that went up is not the enter
348+
// key (13) and the shift key was not held down
349+
// at the same time
350+
if (!event.shiftKey || event.keyCode !== 13) return
351+
// Stop event propagation
352+
event.stopPropagation()
353+
// Prevent the default keyup handler for this element
354+
event.preventDefault()
355+
// ...
356+
}
357+
}
358+
```
359+
309360
### Slots
310361

311362
You can access static slot contents as Arrays of VNodes from [`this.$slots`](http://vuejs.org/v2/api/#vm-slots):
@@ -340,7 +391,7 @@ render (createElement) {
340391
// in the form of { name: props => VNode | Array<VNode> }
341392
scopedSlots: {
342393
default: function (props) {
343-
return h('span', props.text)
394+
return createElement('span', props.text)
344395
}
345396
}
346397
})

src/v2/guide/single-file-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ With `.vue` components, we're entering the realm of advanced JavaScript applicat
4747

4848
After you've taken a day to dive into these resources, we recommend checking out the [webpack-simple](https://github.com/vuejs-templates/webpack-simple) template. Follow the instructions and you should have a Vue project with `.vue` components, ES2015 and hot-reloading running in no time!
4949

50-
The template uses [Webpack](https://webpack.github.io/), a module bundler that takes a number of "modules" and then bundle them into your final application. To learn more about Webpack itself, [this video](https://www.youtube.com/watch?v=WQue1AN93YU) offers a good intro. Once you get past the basics, you might also want to check out [this advanced Webpack course on Egghead.io](https://egghead.io/courses/using-webpack-for-production-javascript-applications).
50+
The template uses [Webpack](https://webpack.github.io/), a module bundler that takes a number of "modules" and then bundles them into your final application. To learn more about Webpack itself, [this video](https://www.youtube.com/watch?v=WQue1AN93YU) offers a good intro. Once you get past the basics, you might also want to check out [this advanced Webpack course on Egghead.io](https://egghead.io/courses/using-webpack-for-production-javascript-applications).
5151

5252
In Webpack, each module can be transformed by a "loader" before being included in the bundle, and Vue offers the [vue-loader](https://github.com/vuejs/vue-loader) plugin to take care of translating `.vue` single-file components. The [webpack-simple](https://github.com/vuejs-templates/webpack-simple) template has already set up everything for you, but if you'd like to learn more about how `.vue` components work with Webpack, you can read [the docs for vue-loader](https://vue-loader.vuejs.org).
5353

src/v2/guide/state-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var store = {
4444
},
4545
clearMessageAction () {
4646
this.debug && console.log('clearMessageAction triggered')
47-
this.state.message = 'action B triggered'
47+
this.state.message = 'clearMessageAction triggered'
4848
}
4949
}
5050
```

src/v2/guide/transitions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 'Transition Effects'
2+
title: Transition Effects
33
type: guide
44
order: 13
55
---
@@ -139,7 +139,7 @@ new Vue({
139139
transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
140140
}
141141
.slide-fade-enter, .slide-fade-leave-active {
142-
padding-left: 10px;
142+
transform: translateX(10px);
143143
opacity: 0;
144144
}
145145
```
@@ -169,7 +169,7 @@ new Vue({
169169
transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
170170
}
171171
.slide-fade-enter, .slide-fade-leave-active {
172-
padding-left: 10px;
172+
transform: translateX(10px);
173173
opacity: 0;
174174
}
175175
</style>

themes/vue/layout/partials/ecosystem_dropdown.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<li><ul>
1212
<li><a href="https://twitter.com/vuejs" class="nav-link" target="_blank">Twitter</a></li>
1313
<li><a href="https://medium.com/the-vue-point" class="nav-link" target="_blank">Blog</a></li>
14-
<li><a href="https://vuejsjob.com/?ref=vuejs" class="nav-link" target="_blank">Jobs</a></li>
14+
<li><a href="https://vuejobs.com/?ref=vuejs" class="nav-link" target="_blank">Jobs</a></li>
1515
</ul></li>
1616
<li><h4>Core Plugins</h4></li>
1717
<li><ul>

themes/vue/layout/partials/language_dropdown.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
<ul class="nav-dropdown">
44
<li><a href="https://cn.vuejs.org/" class="nav-link" target="_blank">中文</a></li>
55
<li><a href="https://jp.vuejs.org/" class="nav-link" target="_blank">日本語</a></li>
6+
<li><a href="https://ru.vuejs.org/" class="nav-link" target="_blank">Русский</a></li>
67
</ul>
78
</li>

themes/vue/layout/partials/sponsors.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
<a href="https://www.2mhost.com/" target="_blank" style="width:90px">
3232
<img src="/images/2mhost.png" style="width:90px">
3333
</a>
34-
<a href="https://vuejsjob.com/?ref=vuejs" target="_blank" style="width:90px;top:5px">
34+
<a href="https://vuejobs.com/?ref=vuejs" target="_blank" style="width:90px;top:5px">
3535
<img src="/images/vuejobs.png" style="width:90px">
3636
</a>

themes/vue/source/css/_demo.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
border 1px solid #eee
33
border-radius $radius
44
padding 25px 35px
5+
margin-top 1em
56
margin-bottom 40px
67
font-size 1.2em
78
line-height 1.5em

themes/vue/source/css/page.styl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@
9393
margin-left 0
9494
iframe
9595
margin 1em 0
96+
> table
97+
border 2px solid $white
98+
margin 1.2em auto
99+
padding: 1em
100+
td, th
101+
line-height 1.6em
102+
padding .5em 1.4em
103+
border none
104+
td
105+
background-color: lighten($codebg, 60%)
106+
th
107+
background-color: $green
108+
color: #fff
109+
padding-top: .85em
110+
padding-bottom .85em
111+
text-align left
112+
tbody
113+
code
114+
background-color #efefef
96115
p.tip
97116
padding 12px 24px 12px 30px
98117
margin 2em 0

0 commit comments

Comments
 (0)