vue-router 跳转页面传递参数并获取参数-------query

我也不知道为什么,我用parms传递传输就是不对,难受

下面是代码

 

 

显示数据的页面

//这个是点击事件,用来传递参数
<el-button size="mini" style="margin-right: 2px" type="text"                     @click.native.prevent="getId(scope.row.id,scope.row.scripttitle,scope.row.scriptcontent)">
                编辑
</el-button> 

//下面是methods中的方法
getId(id,scripttitle,scriptcontent){
      this.$router.push({
        path:'/broad/manuscript/scriptedit',     //这个是你要跳转的路径
        query:{                                 //我用是的query方式,不知为啥params方法不行
          id : id,
          scripttitle : scripttitle,
          scriptcontent : scriptcontent,
        }
      })
    }

下面是回显数据的代码

export default{
  created(){
    this.getParams()
  },
  watch: {
    '$route': 'getParams'
  },

  methods: {
  getParams () {
      // 取到路由带过来的参数 
      const id = this.$route.query.id;
      const _this = this;
      _this.form.scripttitle = this.$route.query.scripttitle;
      _this.form.scriptcontent = this.$route.query.scriptcontent;
      // 将数据放在当前组件的数据内
    }
  }
}

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值