Skip to content

Commit 1a4149e

Browse files
Merge branch 'component-dynamic-async' of github.com:vuejs/docs-next into component-dynamic-async
2 parents 972b85d + 4c9763a commit 1a4149e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/guide/component-dynamic-async.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Earlier, we used the `is` attribute to switch between components in a tabbed interface:
88

9-
```html
9+
```vue-html
1010
<component v-bind:is="currentTabComponent"></component>
1111
```
1212

@@ -18,7 +18,7 @@ You'll notice that if you select a post, switch to the _Archive_ tab, then switc
1818

1919
Recreating dynamic components is normally useful behavior, but in this case, we'd really like those tab component instances to be cached once they're created for the first time. To solve this problem, we can wrap our dynamic component with a `<keep-alive>` element:
2020

21-
```html
21+
```vue-html
2222
<!-- Inactive components will be cached! -->
2323
<keep-alive>
2424
<component v-bind:is="currentTabComponent"></component>
@@ -48,7 +48,7 @@ app.component('async-example', (resolve, reject) => {
4848
setTimeout(() => {
4949
// Pass the component definition to the resolve callback
5050
resolve({
51-
template: '<div>I am async!</div>'
51+
template: '<div>I am async!</div>',
5252
})
5353
}, 1000)
5454
})
@@ -57,7 +57,7 @@ app.component('async-example', (resolve, reject) => {
5757
As you can see, the factory function receives a `resolve` callback, which should be called when you have retrieved your component definition from the server. You can also call `reject(reason)` to indicate the load has failed. The `setTimeout` here is for demonstration; how to retrieve the component is up to you. One recommended approach is to use async components together with [Webpack's code-splitting feature](https://webpack.js.org/guides/code-splitting/):
5858

5959
```js
60-
app.component('async-webpack-example', resolve => {
60+
app.component('async-webpack-example', (resolve) => {
6161
// This special require syntax will instruct Webpack to
6262
// automatically split your built code into bundles which
6363
// are loaded over Ajax requests.
@@ -81,8 +81,8 @@ When using [local registration](components-registration.html#Local-Registration)
8181
new Vue({
8282
// ...
8383
components: {
84-
'my-component': () => import('./my-async-component')
85-
}
84+
'my-component': () => import('./my-async-component'),
85+
},
8686
})
8787
```
8888

@@ -106,7 +106,7 @@ const AsyncComponent = () => ({
106106
delay: 200,
107107
// The error component will be displayed if a timeout is
108108
// provided and exceeded. Default: Infinity.
109-
timeout: 3000
109+
timeout: 3000,
110110
})
111111
```
112112

0 commit comments

Comments
 (0)