vue跳转页面携带参数并且立即执行方法

1.首先定义跳转函数

这个是链接跳转

<a href="javascript:void(0)" onclick="openPage()">位移变化趋势图</a></td></tr>
			</table>
 methods: {
    openPage(){
              // this.$router.push('/dis/show');
        this.$router.push({path: '/dis/show',
        query: {
          searchObj: { type:"monitoring1" ,data:"data_real",begin:"2018-12-20",end:"2018-12-29"}
                 }              
               });

2.跳转页面接收参数

 data() {
        return {
          searchObj:{},
          btnDisabled:false
        }
    },
    created(){
   this.getParams(),
    this.showChart() 
  },
    methods:{
      getParams(){
    // 取到路由带过来的参数赋值给searchObj
    this.searchObj = this.$route.query.searchObj
   },

3.跳转后直接执行方法

在这里插入图片描述
就是在跳转页面直接执行

猜你喜欢

转载自blog.csdn.net/he1234555/article/details/115323866