-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: push before creating Vue instance (#2713)
Fix #2712
- Loading branch information
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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.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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!DOCTYPE html> | ||
<link rel="stylesheet" href="/global.css"> | ||
<a href="/">← Examples index</a> | ||
<div id="app"></div> | ||
|
||
<button id="load-button">Load</button> | ||
<script src="/__build__/shared.chunk.js"></script> | ||
<script src="/__build__/lazy-loading-before-mount.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
'lazy loading before mount': function (browser) { | ||
browser | ||
.url('http://localhost:8080/lazy-loading-before-mount/') | ||
// wait for the Foo component to be resolved | ||
.click('#load-button') | ||
.waitForElementVisible('.foo', 1000) | ||
.assert.containsText('.view', 'This is Foo') | ||
.end() | ||
} | ||
} |