0
点赞
收藏
分享

微信扫一扫

VUE-路由传参数

传参数

  • vue中this.$router.push()路由传值
// 命名的路由
router.push({ name: 'user', params: { userId: 123 }})
 
// 带查询参数,变成/backend/order?selected=2
this.$router.push({path: '/backend/order', query: {selected: "2"}});
 
methods: {
    function(params) {
        //this.$router.push({name:"menuLink",params:{alert:"页面跳转成功"}})
        this.$router.push({name:"menuLink",query: {id:params.id}} } 
    },
}
  • 获取参数的两种常用方法:params和query
//在目标页面通过this.$route.query 获取参数
this.$router.push({path:"/menLink",query:{alert:"页面跳转成功"}})
//用query获取值 <row>提示:{{this.$route.query.alert}}</row>

//menuLink 文件夹中

mounted() {
      this.init();
 },

methods: {
    init() {
        debugger
        let Data = {
            id: this.$route.query.id
        }
    }
}
举报

相关推荐

0 条评论