element Table表格错位,固定fixed错位

表格错位图

 

问题:数据返回会产生从错乱

 1.解决问题

绑定

htmel

 

methods

  doLayout() {

      if (this.$refs.multipleTable) {

        this.$nextTick(() => {

          this.$refs.multipleTable.doLayout()

        })

      }

    },

这里要注意的是要判断$refs

 

watch 监听

竟然是数据返回会导致固定右侧发生错乱,那么就要监听数据返回时调用此方法

 

  watch: {

    tableData(val) {

      this.tableData = val

      this.doLayout()

    },

  }

2.浏览器

上面是数据返回发生错乱,但同样浏览器窗口缩小放大也会产生错乱,这里就要用到 window.onresize监听浏览器窗口

解决:

 在定义data两个变量值

 screenWidth: '',

  screenHeight: ''

 

mounted 

 // fixed浏览器窗口缩小放大导致错位

    this.screenWidth = document.body.clientWidth

    this.screenHeight = document.body.clientHeight

    // 监听浏览器窗口

    window.onresize = () => {

      return (() => {

        this.screenWidth = document.body.clientWidth// 窗口宽度

        this.screenHeight = document.body.clientHeight// 窗口高度

        if (this.screenWidth && this.screenHeight) {

          this.doLayout()// 调用方法

        }

        // console.log(this.screenWidth)

        // console.log(this.screenHeight)

      })()

    }

完毕

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值