当页面有缓存 路由传参无法更新试图 使用watch 进行路由监听

  watch: {
    $route() {
      if (this.$route.path == '/plan/master' && this.$route.query.planName) {
        // sessionStorage.setItem('oldworkorderName','');
        var newName = this.$route.query.planName;//当前页新数据
        // var oldName = this.formInline.planName;//旧的数据
        var oldName = sessionStorage.getItem('oldplanName');//旧的数据
        if (oldName != newName) {//数据有变化时
          sessionStorage.setItem('oldplanName', this.$route.query.planName);
          this.formInline.planName = this.$route.query.planName;
          this.handleSearch()
        }
      }
    

    }
  },
  //Echarts首页跳转
  mounted: function () {
    if (this.$route.query.planName) {
      this.formInline.planName = this.$route.query.planName;
      this.getPlanList();
      sessionStorage.setItem('oldplanName', this.$route.query.planName);
    } else {
     //拉取列表接口
      this.getPlanList();
    }

通过watch监听路由信息  判断this.$route.query实例是否存在 然后将之前的数据存到页面缓存 根据存起来的数据进行判断 赋值后拉去数据

created只会在页面首次加载执行 因为页面有缓存 created 调用不生效 所以用mounted

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

郑源龙

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值