今天在写项目时居然把之前的路由传递参数给忘记了, 故此纪念一下.
首先在你需要跳转路由的模板里面:
- (我的用到了点击事件)
- changePassword(password){
- this.$router.push({name:'changePassword',params:{password:'password'}})
- }
push 的第一个参数就是你要跳转的另一个页面, 第二个参数就是你要传过去的值.
然后再 changePassword 模板里面:
- let password = this.$route.params.password
- console.info(password)
成功打印出来就大功告成了~~~
来源: https://www.2cto.com/kf/201804/736415.html