Skip to content

Commit 8d97edf

Browse files
committed
获取官方最新英文文档更新Merge branch 'master' into 2.0-cn
* master: (38 commits) Fix a typing error. (#507) add source links to api entries remove warning about the migration helper not catching vue-router deprecations yet fix content overlapping sidebar on blog pages, fixes #431 remove wrong statement about el: option. (#504) fix scoping error loadingRouteData example add arbitrary route properties to vue-router migration guide fix subRoutes case typo fix description for router.go deprecation added header background header transition and made it appear on slightly smaller screens to accomodate macbook air 11-inch make mobile bar box shadow more subtle make header mostly transparent on large screens to increase vertical content space make header box shadow more subtle extend sidebar scroll area to left wall Fix variable reference in $mount sample code. (#501) Updated firebase example inputs (#502) fix filter function examples, fixes #503 add vuex migration guide update vue alias instructions fix sidebar not auto-scrolling on api page ... # Conflicts: # src/api/index.md # src/examples/firebase.md # src/guide/components.md # src/guide/events.md # src/guide/instance.md # src/guide/migration-vue-router.md # src/guide/migration.md # src/guide/routing.md # src/guide/single-file-components.md # src/guide/transitions.md # themes/vue/layout/partials/ad.ejs # themes/vue/source/css/page.styl
2 parents 809c7a9 + 379c7b9 commit 8d97edf

35 files changed

+510
-211
lines changed

src/api/index.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ type: api
7777

7878
指定组件的渲染和观察期间未捕获错误的处理函数。这个处理函数被调用时,可获取错误信息和 Vue 实例。
7979

80+
> [Sentry](https://sentry.io), an error tracking service, provides [official integration](https://sentry.io/for/vue/) using this option.
81+
8082
### keyCodes
8183

8284
- **类型:** `{ [key: string]: number }`
@@ -86,10 +88,14 @@ type: api
8688
- **用法:**
8789

8890
``` js
89-
Vue.config.keyCodes = { esc: 27 }
91+
Vue.config.keyCodes = {
92+
v: 86,
93+
f1: 112,
94+
mediaPlayPause: 179
95+
}
9096
```
9197

92-
自定义 v-on 键位别名
98+
v-on 自定义键位别名
9399

94100
## 全局 API
95101

@@ -1173,7 +1179,7 @@ type: api
11731179

11741180
// 或者,在文档之外渲染并且随后挂载
11751181
var component = new MyComponent().$mount()
1176-
document.getElementById('app').appendChild(vm.$el)
1182+
document.getElementById('app').appendChild(component.$el)
11771183
```
11781184

11791185
- **另见:**

src/examples/firebase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ order: 2
55
---
66

77
> 本示例使用 [Firebase](https://firebase.google.com/) 作为数据存储后端,同时在客户端进行数据实时同步(你可以在多个浏览器窗口去打开它来验证)。另外,它通过计算属性实时验证,并且添加/移除选项时触发 CSS 过渡。
8-
<iframe width="100%" height="500" src="https://jsfiddle.net/yyx990803/hkrxmp0h/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
8+
<iframe width="100%" height="500" src="https://jsfiddle.net/chrisvfritz/pyLbpzzx/embedded/result,html,js,css" allowfullscreen="allowfullscreen" frameborder="0"></iframe>

src/guide/comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 对比其他框架
33
type: guide
4-
order: 26
4+
order: 28
55
---
66
这个页面无疑是最难编写的,但我们认为它也是非常重要的。或许你曾遇到了一些问题并且已经用其他的框架解决了。你来这里的目的是看看 Vue 是否有更好的解决方案。这也是我们在此想要回答的。
77

src/guide/components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ new Vue({
212212
</script>
213213
{% endraw %}
214214

215-
### 组合组件
215+
### 构成组件
216216

217217
组件意味着协同工作,通常父子组件会是这样的关系:组件 A 在它的模版中使用了组件 B 。它们之间必然需要相互通信:父组件要给子组件传递数据,子组件需要将它内部发生的事情告知给父组件。然而,在一个良好定义的接口中尽可能将父子组件解耦是很重要的。这保证了每个组件可以在相对隔离的环境中书写和理解,也大幅提高了组件的可维护性和可重用性。
218218

src/guide/deployment.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
title: Deploying For Production
3+
type: guide
4+
order: 20
5+
---
6+
7+
## Stripping Out Warnings
8+
9+
The minified standalone build of Vue has already stripped out all the warnings for you for a smaller file size, but when you are using tools like Webpack or Browserify, you will need some additional configuration to achieve this.
10+
11+
### Webpack
12+
13+
Use Webpack's [DefinePlugin](http://webpack.github.io/docs/list-of-plugins.html#defineplugin) to indicate a production environment, so that warning blocks can be automatically dropped by UglifyJS during minification. Example config:
14+
15+
``` js
16+
var webpack = require('webpack')
17+
18+
module.exports = {
19+
// ...
20+
plugins: [
21+
// ...
22+
new webpack.DefinePlugin({
23+
'process.env': {
24+
NODE_ENV: '"production"'
25+
}
26+
}),
27+
new webpack.optimize.UglifyJsPlugin({
28+
compress: {
29+
warnings: false
30+
}
31+
})
32+
]
33+
}
34+
```
35+
36+
### Browserify
37+
38+
- Run your bundling command with `NODE_ENV` set to `"production"`. This tells `vueify` to avoid including hot-reload and development related code.
39+
- Apply a global [envify](https://github.com/hughsk/envify) transform to your bundle. This allows the minifier to strip out all the warnings in Vue's source code wrapped in env variable conditional blocks. For example:
40+
41+
42+
``` bash
43+
NODE_ENV=production browserify -g envify -e main.js | uglifyjs -c -m > build.js
44+
```
45+
46+
- To extract styles to a separate css file use a extract-css plugin which is included in vueify.
47+
48+
``` bash
49+
NODE_ENV=production browserify -g envify -p [ vueify/plugins/extract-css -o build.css ] -e main.js | uglifyjs -c -m > build.js
50+
```
51+
52+
## Tracking Runtime Errors
53+
54+
If a runtime error occurs during a component's render, it will be passed to the global `Vue.config.errorHandler` config function if it has been set. It might be a good idea to leverage this hook together with an error-tracking service like [Sentry](https://sentry.io), which provides [an official integration](https://sentry.io/for/vue/) for Vue.
55+
56+
## Extracting CSS
57+
58+
When using [Single-File Components](./single-file-components.html), the `<style>` tags are injected dynamically at runtime during development. In production you may want to extract the styles across all components into a single CSS file. For details on how to achieve this, consult the respective documentation for [vue-loader](http://vue-loader.vuejs.org/en/configurations/extract-css.html) and [vueify](https://github.com/vuejs/vueify#css-extraction).
59+
60+
The official `webpack` template from `vue-cli` has this already configured out of the box.

src/guide/events.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ methods: {
175175
<form v-on:submit.prevent="onSubmit"></form>
176176

177177
<!-- 修饰符可以串联 -->
178-
<a v-on:click.stop.prevent="doThat">
178+
<a v-on:click.stop.prevent="doThat"></a>
179179

180180
<!-- 只有修饰符 -->
181181
<form v-on:submit.prevent></form>
@@ -218,13 +218,7 @@ methods: {
218218
- left
219219
- right
220220

221-
同样支持单字母按键别名。
222-
223-
``` html
224-
<input v-on:keyup.v="say('That is the first letter in Vue')">
225-
```
226-
227-
在必要时,甚至可以自定义按键别名:
221+
可以通过全局 `config.keyCodes` 对象[自定义按键修饰符别名](/api/#keyCodes)
228222

229223
``` js
230224
// 可以使用 @keyup.f1

src/guide/forms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ new Vue({
3636

3737
``` html
3838
<span>Multiline message is:</span>
39-
<p>{{ message }}</p>
39+
<p style="white-space: pre">{{ message }}</p>
4040
<br>
4141
<textarea v-model="message" placeholder="add multiple lines"></textarea>
4242
```

src/guide/installation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ $ npm install vue
5959
``` js
6060
resolve: {
6161
alias: {
62-
vue: 'vue/dist/vue.js'
62+
'vue$': 'vue/dist/vue.js'
6363
}
6464
}
6565
```

src/guide/instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ vm.$watch('a', function (newVal, oldVal) {
7373
})
7474
```
7575

76-
<p class="tip">注意,不要在实例属性或者回调函数中(如 `vm.$watch('a', newVal => this.myMethod())`)使用箭头函数。原因是箭头函数绑定父上下文,所以 `this` 不会像预想的一样是 Vue 实例,而是 `this.myMethod` 未被定义。</p>
76+
<p class="tip">注意,不要在实例属性或者回调函数中(如 `vm.$watch('a', newVal => this.myMethod())`)使用[箭头函数](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions)。因为箭头函数绑定父上下文,所以 `this` 不会像预想的一样是 Vue 实例,而是 `this.myMethod` 未被定义。</p>
7777

7878
实例属性和方法的完整列表中查阅 [API 参考](/api)
7979

src/guide/join.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: 加入Vue.js社区
33
type: guide
4-
order: 27
4+
order: 29
55
---
66

77
Vue.js 的社区正在急速增长中,如果你正在阅读本文,这是你准备好加入 Vue.js 社区的大好机会。欢迎!

src/guide/migration-vue-router.md

Lines changed: 89 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,51 @@
11
---
22
title: 从Vue Router 0.7.x迁移
33
type: guide
4-
order: 25
4+
order: 26
55
---
66

77
> 只有Vue Router 2与Vue 2是相互兼容的,所以如果你需要更新Vue,你也需要更新Vue Router。这也就是我们在主文档中将迁移路径的内容添加进来的原因。
88
如果想要进一步了解新Vue Router的使用详情,请移步 [Vue Router docs](http://router.vuejs.org/en/).
99

10-
<p class="tip">以下的弃用名单应该相对完整,但是迁移助手会不定期更新以保证赶上更新的进度.</p>
10+
11+
## Router Initialization
12+
13+
### `router.start` <sup>deprecated</sup>
14+
15+
There is no longer a special API to initialize an app with Vue Router. That means instead of:
16+
17+
``` js
18+
router.start({
19+
template: '<router-view></router-view>'
20+
}, '#app')
21+
```
22+
23+
You'll just pass a router property to a Vue instance:
24+
25+
``` js
26+
new Vue({
27+
el: '#app',
28+
router: router,
29+
template: '<router-view></router-view>'
30+
})
31+
```
32+
33+
Or, if you're using the runtime-only build of Vue:
34+
35+
``` js
36+
new Vue({
37+
el: '#app',
38+
router: router,
39+
render: h => h('router-view')
40+
})
41+
```
42+
43+
{% raw %}
44+
<div class="upgrade-path">
45+
<h4>Upgrade Path</h4>
46+
<p>Run the <a href="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of <code>router.start</code> being called.</p>
47+
</div>
48+
{% endraw %}
1149

1250
## Route 定义
1351

@@ -92,14 +130,14 @@ router.match = createMatcher(
92130
</div>
93131
{% endraw %}
94132

95-
### `subroutes` <sup>弃用</sup>
133+
### `subRoutes` <sup>弃用</sup>
96134

97135
[重命名为`children`](http://router.vuejs.org/en/essentials/nested-routes.html)出于与Vue以及其他路由库的一致性考虑.
98136

99137
{% raw %}
100138
<div class="upgrade-path">
101139
<h4>升级路径</h4>
102-
<p>运行<a href="https://github.com/vuejs/vue-migration-helper">迁移助手</a>命令去寻找示例<code>subroutes</code>的选项.</p>
140+
<p>运行 <a href="https://github.com/vuejs/vue-migration-helper">迁移助手</a>命令去寻找示例 <code>subRoutes</code> 的选项</p>
103141
</div>
104142
{% endraw %}
105143

@@ -162,6 +200,44 @@ alias: ['/manage', '/administer', '/administrate']
162200
</div>
163201
{% endraw %}
164202

203+
### Arbitrary Route Properties
204+
205+
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:
206+
207+
``` js
208+
'/admin': {
209+
component: AdminPanel,
210+
requiresAuth: true
211+
}
212+
```
213+
214+
Then you would now update it to:
215+
216+
``` js
217+
{
218+
path: '/admin',
219+
component: AdminPanel,
220+
meta: {
221+
requiresAuth: true
222+
}
223+
}
224+
```
225+
226+
Then when later accessing this property on a route, you will still go through meta. For example:
227+
228+
``` js
229+
if (route.meta.requiresAuth) {
230+
// ...
231+
}
232+
```
233+
234+
{% raw %}
235+
<div class="upgrade-path">
236+
<h4>Upgrade Path</h4>
237+
<p>Run the <a href="https://github.com/vuejs/vue-migration-helper">migration helper</a> on your codebase to find examples of arbitrary route properties not scoped under meta.</p>
238+
</div>
239+
{% endraw %}
240+
165241
## Route 匹配
166242

167243
路由匹配现在使用[path-to-regexp](https://github.com/pillarjs/path-to-regexp)这个包,这将会使得工作与之前相比更加灵活.
@@ -232,12 +308,12 @@ alias: ['/manage', '/administer', '/administrate']
232308

233309
### `router.go`
234310

235-
[重命名为`router.push`](http://router.vuejs.org/en/essentials/navigation.html#routerpushlocation) 出于在[HTML5 History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)与语使用的一致性原则.
311+
为了与 [HTML5 History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) 保持一致性,`router.go` 已经被用来作为 [后退/前进导航](https://router.vuejs.org/en/essentials/navigation.html#routergon)[`router.push` ](http://router.vuejs.org/en/essentials/navigation.html#routerpushlocation) 用来导向特殊页面。
236312

237313
{% raw %}
238314
<div class="upgrade-path">
239315
<h4>升级路径</h4>
240-
<p>运行<a href="https://github.com/vuejs/vue-migration-helper">迁移助手</a>命令去寻找<code>router.go</code>指令被调用的示例</p>
316+
<p>运行<a href="https://github.com/vuejs/vue-migration-helper">迁移助手</a>命令, 寻找 <code>router.go</code> 和 <code>router.push</code> 指令被调用的示例</p>
241317
</div>
242318
{% endraw %}
243319

@@ -456,20 +532,22 @@ data: function () {
456532
},
457533
watch: {
458534
'$route': function () {
459-
this.isLoading = true
460-
this.fetchData().then(() => {
461-
this.isLoading = false
535+
var self = this
536+
self.isLoading = true
537+
self.fetchData().then(function () {
538+
self.isLoading = false
462539
})
463540
}
464541
},
465542
methods: {
466543
fetchData: function () {
544+
var self = this
467545
return axios.get('/api/posts')
468546
.then(function (response) {
469-
this.posts = response.data.posts
547+
self.posts = response.data.posts
470548
})
471549
.catch(function (error) {
472-
this.fetchError = error
550+
self.fetchError = error
473551
})
474552
}
475553
}

0 commit comments

Comments
 (0)