-
-
Notifications
You must be signed in to change notification settings - Fork 5k
/
Copy pathapp.js
41 lines (36 loc) · 819 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const Home = { template: '<div>Home</div>' }
const Foo = () =>
new Promise(resolve => {
setTimeout(() =>
resolve({
template: `<div class="foo">This is Foo</div>`
})
, 10)
})
const router = new VueRouter({
mode: 'history',
base: __dirname,
routes: [
{ path: '/', component: Home },
// Just use them normally in the route config
{ path: '/async', component: Foo }
]
})
router.onReady(() => {
router.push('/async')
})
document.getElementById('load-button').addEventListener('click', (event) => {
new Vue({
router,
template: `
<div id="app">
<h1>Async</h1>
<router-view class="view"></router-view>
</div>
`
}).$mount('#app')
event.target.remove()
})