登录社区云,与社区用户共同成长
邀请您加入社区
params 的应用返回前的页面设置参数this.$route.params.a = 'a';this.$route.params.b = 'b';返回的目标页面获取参数beforeRouteEnter(to, from, next) {const { a, b} = from.params; // 'a' 'b'// 此处无法直接设置 this.a this.bnext();}created()
返回前页面1设置参数
页面1
this.$route.params.a = 'a'; this.$route.params.b = 'b';
返回后页面2获取参数
页面2
let pA,pB; beforeRouteEnter(to, from, next) { // 此处无法直接设置 this.a this.b pA = from.params.a; // 'a' pB = from.params.b; // 'b' next(); // 必需调用 } created() { console.log(pA, pB); // 'a' 'b' }
这里使用了导航守卫
Vue社区为您提供最前沿的新闻资讯和知识内容
更多推荐
Mac 使用vscode 创建vue项目后修改文件提示:权限不足,以超级用户身份重试
基于nodejs+vue云计算的城乡医疗卫生服务系统[程序+论文+开题]-计算机毕业设计
ElasticSearch迁移至openGauss
扫一扫分享内容
所有评论(0)