export default {
  data() {
    return {
      tempSpan: document.createElement('div'),
    }
  },
  mounted() {
    this.tempSpan.style.visibility = 'hidden'
    this.tempSpan.style.position = 'absolute'
    this.tempSpan.style['white-space'] =  'break-spaces'
    this.tempSpan.style['word-break'] =  'break-all'
   
    document.body.appendChild(this.tempSpan)
  },
  beforeDestroy() {
    document.body.removeChild(this.tempSpan)
  },
  methods:{
    getDivHeight(s,vs,w,v){
      this.tempSpan.style.fontSize = s + 'px'
      const lineHeight = (Number(s || '0') + Number(vs || '0'))
      this.tempSpan.style.lineHeight = lineHeight + 'px'
  
      this.tempSpan.style.width = w + 'px'
      this.tempSpan.innerHTML = v
  
      let rect = this.tempSpan.getBoundingClientRect()
      return rect.height
    }
  }
}