vue push 同一个路由,到当前页面的时候刷新数据

业务场景是这样子的,我从

 点击搜索框输入搜索,跳转提油页,发现在促销界面点击不会发起请求,因为顶部的区域是写在公共组件里的,那怎么才刷新呢


// main.vue 文件
 
this.$router.push({
        name: 'salepomption',
        params: { timestamp: (new Date()).valueOf()},
        query: { code: this.searchData, timestamp: (new Date()).valueOf() }
      })


// 跳转到指定页刷新

watch: {
    $route: {
      immediate: true, // 一旦监听到路由的变化立即执行
      handler (to, from) {
        this.init()
      }
    }
  },

  methods: {
    init () {
      this.conditions.oilModel = this.$route.query.code ? this.$route.query.code : ''
      this.getOilModeldata()
      this.getPomoOilData()
      this.getOilAreadata(this.dataParams)
    },
  },

猜你喜欢

转载自blog.csdn.net/weixin_40918145/article/details/120514217