扫码关注官方订阅号
如题Italic
闭关修行中......
const a = { b:1, c:2 } new Vue({ data: a })
不知道你要传入什么data,不过你可以试试用beforeRouteEnter钩子,这时机应该是你想要的:
beforeRouteEnter
beforeRouteEnter (to, from, next) { next(vm => { // 通过 `vm` 访问组件实例 }) }
详情请看文档
你可能需要动态路由设置?你这问题描述太抽象只能猜测,有了动态路由你就可以愉快的在<router-link :to="{path: '/'}"></router-link>中拼接路径了,祝你好运
<router-link :to="{path: '/'}"></router-link>
https://router.vuejs.org/zh-c...
动态路由,然后用$route.params去获取路由对象里的信息详情可以去看vue router的官方文档下面是我最近写的例子route.js
export default new Router({ routes: [ { path: '/', name: 'index', component: index }, { path: '/list/:category', name: "list", component: list, meta: { id: 'list-kind' } } ] })
parent.vue
<router-link :to="{ path: './list/learn'}" tag="section" class="item"> <img src="../assets/h5_icon_1.png" alt="Subject Learn"> <p>It is a learning fairyland for Chinese learners</p> </router-link>
child.vue
created(){ this.fetch(); this.title = this.$route.params.category.toUpperCase(); }
在router路由上定义
{ path: 'courseContent/:lassId',name:'courseContent', component: CourseContent }
在跳转的地方
this.$router.replace({name:'electiveCourse',params:{classId:this.classId}});
新界面接收
this.$route.params.classId
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
不知道你要传入什么data,不过你可以试试用
beforeRouteEnter钩子,这时机应该是你想要的:详情请看文档
https://router.vuejs.org/zh-c...
动态路由,然后用$route.params去获取路由对象里的信息
详情可以去看vue router的官方文档
下面是我最近写的例子
route.js
parent.vue
child.vue
在router路由上定义
在跳转的地方
新界面接收