Skip to content

Commit 6c22374

Browse files
Merge branch 'master' of github.com:vuejs/docs-next
2 parents eac3457 + e5b34b2 commit 6c22374

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

src/guide/component-dynamic-async.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ Check out more details on `<keep-alive>` in the [API reference](../api/built-in-
3838
In large applications, we may need to divide the app into smaller chunks and only load a component from the server when it's needed. To make that possible, Vue has a `defineAsyncComponent` method:
3939

4040
```js
41-
const app = Vue.createApp({})
41+
const { createApp, defineAsyncComponent } = Vue
4242

43-
const AsyncComp = Vue.defineAsyncComponent(
43+
const app = createApp({})
44+
45+
const AsyncComp = defineAsyncComponent(
4446
() =>
4547
new Promise((resolve, reject) => {
4648
resolve({

src/guide/render-function.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,13 @@ render() {
366366

367367
For all other event and key modifiers, no special API is necessary, because we can use event methods in the handler:
368368

369-
| Modifier(s) | Equivalent in Handler |
370-
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
371-
| `.stop` | `event.stopPropagation()` |
372-
| `.prevent` | `event.preventDefault()` |
373-
| `.self` | `if (event.target !== event.currentTarget) return` |
374-
| Keys:<br>`.enter`, `.13` | `if (event.keyCode !== 13) return` (change `13` to [another key code](http://keycode.info/) for other key modifiers) |
375-
| Modifiers Keys:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return` (change `ctrlKey` to `altKey`, `shiftKey`, or `metaKey`, respectively) |
369+
| Modifier(s) | Equivalent in Handler |
370+
| ---------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
371+
| `.stop` | `event.stopPropagation()` |
372+
| `.prevent` | `event.preventDefault()` |
373+
| `.self` | `if (event.target !== event.currentTarget) return` |
374+
| Keys:<br>e.g. `.enter` | `if (event.key !== 'Enter') return`<br><br>Change `'Enter'` to the appropriate [key](http://keycode.info/) |
375+
| Modifier Keys:<br>`.ctrl`, `.alt`, `.shift`, `.meta` | `if (!event.ctrlKey) return`<br><br>Likewise for `altKey`, `shiftKey`, and `metaKey` |
376376

377377
Here's an example with all of these modifiers used together:
378378

@@ -384,9 +384,9 @@ render() {
384384
// the element the event is bound to
385385
if (event.target !== event.currentTarget) return
386386
// Abort if the key that went up is not the enter
387-
// key (13) and the shift key was not held down
388-
// at the same time
389-
if (!event.shiftKey || event.keyCode !== 13) return
387+
// key and the shift key was not held down at the
388+
// same time
389+
if (!event.shiftKey || event.key !== 'Enter') return
390390
// Stop event propagation
391391
event.stopPropagation()
392392
// Prevent the default keyup handler for this element

src/guide/routing.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ For most Single Page Applications, it's recommended to use the officially-suppor
99
If you only need very simple routing and do not wish to involve a full-featured router library, you can do so by dynamically rendering a page-level component like this:
1010

1111
```js
12+
const { createApp, h } = Vue
13+
1214
const NotFoundComponent = { template: '<p>Page not found</p>' }
1315
const HomeComponent = { template: '<p>Home page</p>' }
1416
const AboutComponent = { template: '<p>About page</p>' }
@@ -30,11 +32,11 @@ const SimpleRouter = {
3032
},
3133

3234
render() {
33-
return Vue.h(this.CurrentComponent)
35+
return h(this.CurrentComponent)
3436
}
3537
}
3638

37-
Vue.createApp(SimpleRouter).mount('#app')
39+
createApp(SimpleRouter).mount('#app')
3840
```
3941

4042
Combined with the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API), you can build a very basic but fully-functional client-side router. To see that in practice, check out [this example app](https://github.com/phanan/vue-3.0-simple-routing-example).

src/guide/state-management.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ If you're coming from React, you may be wondering how vuex compares to [redux](h
1313
It is often overlooked that the source of truth in Vue applications is the reactive `data` object - a component instance only proxies access to it. Therefore, if you have a piece of state that should be shared by multiple instances, you can use a [reactive](/guide/reactivity-fundamentals.html#declaring-reactive-state) method to make an object reactive:
1414

1515
```js
16-
const sourceOfTruth = Vue.reactive({
16+
const { createApp, reactive } = Vue
17+
18+
const sourceOfTruth = reactive({
1719
message: 'Hello'
1820
})
1921

20-
const appA = Vue.createApp({
22+
const appA = createApp({
2123
data() {
2224
return sourceOfTruth
2325
}
2426
}).mount('#app-a')
2527

26-
const appB = Vue.createApp({
28+
const appB = createApp({
2729
data() {
2830
return sourceOfTruth
2931
}
@@ -39,7 +41,7 @@ const appB = Vue.createApp({
3941
Now whenever `sourceOfTruth` is mutated, both `appA` and `appB` will update their views automatically. We have a single source of truth now, but debugging would be a nightmare. Any piece of data could be changed by any part of our app at any time, without leaving a trace.
4042

4143
```js
42-
const appB = Vue.createApp({
44+
const appB = createApp({
4345
data() {
4446
return sourceOfTruth
4547
},
@@ -55,7 +57,7 @@ To help solve this problem, we can adopt a **store pattern**:
5557
const store = {
5658
debug: true,
5759

58-
state: Vue.reactive({
60+
state: reactive({
5961
message: 'Hello!'
6062
}),
6163

@@ -88,7 +90,7 @@ In addition, each instance/component can still own and manage its own private st
8890
```
8991

9092
```js
91-
const appA = Vue.createApp({
93+
const appA = createApp({
9294
data() {
9395
return {
9496
privateState: {},
@@ -100,7 +102,7 @@ const appA = Vue.createApp({
100102
}
101103
}).mount('#app-a')
102104

103-
const appB = Vue.createApp({
105+
const appB = createApp({
104106
data() {
105107
return {
106108
privateState: {},

0 commit comments

Comments
 (0)