You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/guide/component-dynamic-async.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -38,9 +38,11 @@ Check out more details on `<keep-alive>` in the [API reference](../api/built-in-
38
38
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:
Copy file name to clipboardExpand all lines: src/guide/routing.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ For most Single Page Applications, it's recommended to use the officially-suppor
9
9
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:
10
10
11
11
```js
12
+
const { createApp, h } = Vue
13
+
12
14
constNotFoundComponent= { template:'<p>Page not found</p>' }
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).
Copy file name to clipboardExpand all lines: src/guide/state-management.md
+9-7Lines changed: 9 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -13,17 +13,19 @@ If you're coming from React, you may be wondering how vuex compares to [redux](h
13
13
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:
14
14
15
15
```js
16
-
constsourceOfTruth=Vue.reactive({
16
+
const { createApp, reactive } = Vue
17
+
18
+
constsourceOfTruth=reactive({
17
19
message:'Hello'
18
20
})
19
21
20
-
constappA=Vue.createApp({
22
+
constappA=createApp({
21
23
data() {
22
24
return sourceOfTruth
23
25
}
24
26
}).mount('#app-a')
25
27
26
-
constappB=Vue.createApp({
28
+
constappB=createApp({
27
29
data() {
28
30
return sourceOfTruth
29
31
}
@@ -39,7 +41,7 @@ const appB = Vue.createApp({
39
41
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.
40
42
41
43
```js
42
-
constappB=Vue.createApp({
44
+
constappB=createApp({
43
45
data() {
44
46
return sourceOfTruth
45
47
},
@@ -55,7 +57,7 @@ To help solve this problem, we can adopt a **store pattern**:
55
57
conststore= {
56
58
debug:true,
57
59
58
-
state:Vue.reactive({
60
+
state:reactive({
59
61
message:'Hello!'
60
62
}),
61
63
@@ -88,7 +90,7 @@ In addition, each instance/component can still own and manage its own private st
0 commit comments