Vue.js v1.0.28 / vue-router v0.7.13
路由切换已经实现。但我想用$route.params.* ,向同一个子组件传送不同的数据,可是无法实现,请教错在哪?
<body>
<div id="app"></div>
<!-- 父模板 -->
<template id="parent">
<div class="parent">
<router-view></router-view>
<nav>
<a v-link="{ path: '/child',params: { a: 1 } }">child-1</a>
<a v-link="{ path: '/child',params: { a: 2 } }">child-2</a>
<a v-link="{ path: '/other' }">other</a>
</nav>
</div>
</template>
<script>
child = Vue.extend({template: '<div class="round">子:{{$route.params.a}}</div>' });
other = Vue.extend({template: '<div class="round">other</div>'});
parent = Vue.extend({template: '#parent'})
Vue.use(VueRouter);
var router = new VueRouter();
router.map({
'/child': {component: child },
'/other': {component: other }
});
router.start(parent, '#app');
router.go({"path":"/child"} );
</script>
</body>
已经找到了答案: