vue的路由穿参

今天在写项目时居然把之前的路由传递参数给忘记了,故此纪念一下。

首先在你需要跳转路由的模板里面:
(我的用到了点击事件)

changePassword(password){
    this.$router.push({name:'changePassword',params:{password:'password'}})
}
push的第一个参数就是你要跳转的另一个页面,第二个参数就是你要传过去的值。

然后再changePassword模板里面:

let password = this.$route.params.password
console.info(password)

成功打印出来就大功告成了~~~

猜你喜欢

转载自blog.csdn.net/github_39088222/article/details/79856050