vue跨页面传参

例:登录页和首页

登录页点击登录跳转到首页的时候,添加该参数:

this.$router.replace({ path: '/Testing' ,query:{id:'1',name:this.ruleForm2.account}});

 然后在首页获取参数:

export default {
		created() {
			console.log(this.$route.query.name);
			this.sysUserName = this.$route.query.name
		},
		data() {}
}

成品:

  

不过这种有个缺点,就是参数在url上!

原文地址:https://www.cnblogs.com/moguzi12345/p/12789581.html