Skip to content

Commit ec6eab7

Browse files
authoredApr 17, 2019
fix: revert #2713 (#2723)
Closes #2719
1 parent 8e55ae1 commit ec6eab7

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed
 

‎examples/basic/app.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const router = new VueRouter({
2929
// Route components will be rendered inside <router-view>.
3030
new Vue({
3131
router,
32+
data: () => ({ n: 0 }),
3233
template: `
3334
<div id="app">
3435
<h1>Basic</h1>
@@ -43,9 +44,22 @@ new Vue({
4344
<li><router-link to="/é?t=%25ñ">/é?t=%ñ</router-link></li>
4445
<li><router-link to="/é#%25ñ">/é#%25ñ</router-link></li>
4546
</ul>
47+
<button id="navigate-btn" @click="navigateAndIncrement">On Success</button>
48+
<pre id="counter">{{ n }}</pre>
4649
<pre id="query-t">{{ $route.query.t }}</pre>
4750
<pre id="hash">{{ $route.hash }}</pre>
4851
<router-view class="view"></router-view>
4952
</div>
50-
`
53+
`,
54+
55+
methods: {
56+
navigateAndIncrement () {
57+
const increment = () => this.n++
58+
if (this.$route.path === '/') {
59+
this.$router.push('/foo', increment)
60+
} else {
61+
this.$router.push('/', increment)
62+
}
63+
}
64+
}
5165
}).$mount('#app')

‎examples/lazy-loading-before-mount/app.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const router = new VueRouter({
2323
]
2424
})
2525

26-
router.push('/async')
26+
router.onReady(() => {
27+
router.push('/async')
28+
})
2729

2830
document.getElementById('load-button').addEventListener('click', (event) => {
2931
new Vue({

‎examples/lazy-loading/app.js

+13
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@ const router = new VueRouter({
4343
{ path: '/', component: Home },
4444
// Just use them normally in the route config
4545
{ path: '/foo', component: Foo },
46+
// mulitple parameters, `/` should not be encoded. The name is also important
47+
// https://github.com/vuejs/vue-router/issues/2719
48+
{ path: '/a/:tags*', name: 'tagged', component: () => new Promise(resolve => {
49+
setTimeout(() => {
50+
resolve({
51+
template: `<div>
52+
<h2>Lazy with params</h2>
53+
<pre id="tagged-path">{{ $route.path }}</pre>
54+
</div>`
55+
})
56+
}, 200)
57+
}) },
4658
// Bar and Baz belong to the same root route
4759
// and grouped in the same async chunk.
4860
{ path: '/bar', component: Bar,
@@ -63,6 +75,7 @@ new Vue({
6375
<li><router-link to="/foo">/foo</router-link></li>
6476
<li><router-link to="/bar">/bar</router-link></li>
6577
<li><router-link to="/bar/baz">/bar/baz</router-link></li>
78+
<li><router-link to="/a/b/c">/a/b/c</router-link></li>
6679
</ul>
6780
<router-view class="view"></router-view>
6881
</div>

‎src/util/resolve-components.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
3030
match.components[key] = resolvedDef
3131
pending--
3232
if (pending <= 0) {
33-
next(to)
33+
next()
3434
}
3535
})
3636

‎test/e2e/specs/basic.js

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ module.exports = {
4040
.url('http://localhost:8080/basic/%C3%A9')
4141
.waitForElementVisible('#app', 1000)
4242
.assert.containsText('.view', 'unicode')
43+
44+
// regression onComplete
45+
// https://github.com/vuejs/vue-router/issues/2721
46+
.assert.containsText('#counter', '0')
47+
.click('#navigate-btn')
48+
.assert.containsText('#counter', '1')
49+
.click('#navigate-btn')
50+
.assert.containsText('#counter', '2')
51+
4352
.end()
4453
}
4554
}

‎test/e2e/specs/lazy-loading.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
browser
44
.url('http://localhost:8080/lazy-loading/')
55
.waitForElementVisible('#app', 1000)
6-
.assert.count('li a', 4)
6+
.assert.count('li a', 5)
77
.assert.containsText('.view', 'home')
88

99
.click('li:nth-child(2) a')
@@ -28,6 +28,18 @@ module.exports = {
2828
.waitForElementVisible('#app', 1000)
2929
.assert.containsText('.view', 'This is Bar!')
3030
.assert.containsText('.view h3', 'Baz')
31+
32+
// lazy loading with dynamic params: https://github.com/vuejs/vue-router/issues/2719
33+
// direct visit
34+
.url('http://localhost:8080/lazy-loading/a/b/c')
35+
.waitForElementVisible('#app', 1000)
36+
.assert.containsText('.view', '/a/b/c')
37+
// coming from another url
38+
.url('http://localhost:8080/lazy-loading/')
39+
.waitForElementVisible('#app', 1000)
40+
.click('li:nth-child(5) a')
41+
.waitForElementVisible('#tagged-path', 1000)
42+
.assert.containsText('.view', '/a/b/c')
3143
.end()
3244
}
3345
}

0 commit comments

Comments
 (0)