扫码关注官方订阅号
点击一个按钮,跳转router时 ,怎么做到,将 指定的值(这个值是有2中情况的)传入到组件中,过度。
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
用导航钩子函数https://router.vuejs.org/zh-c...
<p id="app"> <router-link to="/a">aaaa</router-link> <router-link to="/b">index</router-link> <transition :name="v"> <router-view ></router-view> </transition> </p> const router = new VueRouter({ routes: [ { path: '/a', component: { template: '<span>a</span>' } }, { path: '/b', component: {template: '<span>b</span>'} } ] }) var app = new Vue({ el: '#app', data: { v: 1 }, router, watch: { '$route'(to,from){ this.v = 2; } } });
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
用导航钩子函数
https://router.vuejs.org/zh-c...