加上if判断,先判断是否存在,否则不执行

 this.getTitleTopY = debounce(() => {
      if (this.$refs.param && this.$refs.comment && this.$refs.goodsList) {
        this.$nextTick(() => {
          //获取不同组件的offsetTop
          this.titleTopY = [];
          this.titleTopY.push(0);
          this.titleTopY.push(this.$refs.param.$el.offsetTop - 44);
          this.titleTopY.push(this.$refs.comment.$el.offsetTop - 44);
          this.titleTopY.push(this.$refs.goodsList.$el.offsetTop - 44);
          this.titleTopY.push(Number.MAX_VALUE);
          console.log("我");
        });
      }
    }, 500);

相关文章:

  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-05-05
  • 2021-08-04
  • 2022-01-16
相关资源
相似解决方案