vue 动态获取宽

// 获取页面div的宽度
getWidth() {
  this.$nextTick(() => {
    let treeContainer = this.$refs.treeContainer.clientWidth // 最外边的长度
    this.tableTreeTwo = (treeContainer/4)*2-18 + "px"
   //  let tableTreeRight = this.$refs.tableTreeRight.clientWidth
   // this.tableTreeOne = (tableTreeRight - (treeContainer/3)*2) + 'px'
   //  console.log(this.tableTreeOne)
  })

}

有的时候获取不到可以用this.$nextTick

你可能感兴趣的:(vue)