Skip to content

Commit 22971e4

Browse files
committed
Implemented example showing passing params via push does not work
1 parent 69ce269 commit 22971e4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

examples/basic/app.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ Vue.use(VueRouter)
1010
const Home = { template: '<div>home</div>' }
1111
const Foo = { template: '<div>foo</div>' }
1212
const Bar = { template: '<div>bar</div>' }
13+
const Foobar = {
14+
template: `
15+
<div>
16+
<p>prop: {{fooParam}}</p>
17+
<p>params: {{$route.params}}</p>
18+
</div>'
19+
`,
20+
props: ['fooParam']
21+
}
1322

1423
// 3. Create the router
1524
const router = new VueRouter({
@@ -18,14 +27,21 @@ const router = new VueRouter({
1827
routes: [
1928
{ path: '/', component: Home },
2029
{ path: '/foo', component: Foo },
21-
{ path: '/bar', component: Bar }
30+
{ path: '/bar', component: Bar },
31+
{ path: '/foobar/:fooParam?', component: Foobar, props: true }
2232
]
2333
})
2434

2535
// 4. Create and mount root instance.
2636
// Make sure to inject the router.
2737
// Route components will be rendered inside <router-view>.
2838
new Vue({
39+
mounted() {
40+
setTimeout(() => {
41+
alert('Navigating to `/foobar` with params')
42+
this.$router.push({ path: '/foobar', params: { fooParam: 'FooBar' } });
43+
}, 2000);
44+
},
2945
router,
3046
template: `
3147
<div id="app">
@@ -37,6 +53,7 @@ new Vue({
3753
<router-link tag="li" to="/bar" :event="['mousedown', 'touchstart']">
3854
<a>/bar</a>
3955
</router-link>
56+
<li><router-link to="/foobar/someParameterValue">/foobar/someParameterValue</router-link></li>
4057
</ul>
4158
<router-view class="view"></router-view>
4259
</div>

0 commit comments

Comments
 (0)