先看代码

// 判断是否有元素超出显示框
        checkIfOverflow () {
            console.log('aaa', this.$refs)
            let refName = 'dataList' + this.selectType
            console.log('refName:', refName)
            let selecteList = this.$refs[refName].childNodes
            // let selecteList = this.$refs['selectType' + this.selectType].childNodes
            // let firstChild = selecteList[0]
            // let lastChild = selecteList[selecteList.length - 1]
            console.log('typeof selecteList:', typeof selecteList, selecteList)
            this.$nextTick(() => {
                let arr = this.$refs['dataListItem']
                if (arr[0].offsetTop !== arr[arr.length - 1].offsetTop) {
                    this.inputOverflow = true
                }
            })
            // console.log('offsetTops:', this.$refs[refName + 0], this.$refs.dataListItem)
            // let arr = this.$refs
            // let arr2 = this.$refs['dataListItem']
            // console.log('arr:', arr, arr2)
            // arr.forEach((item, index) => {
            //     console.log(item.offsetTop)
            // })
            // let arr = []
            // for (var i = 0; i < selecteList.length; i++) { 
            //     var ele = selecteList[i]
            //     arr.push(ele)
            // } 
            // console.log('arr', arr)
            // console.log('firstChild:', firstChild)
            // console.log('lastChild:', lastChild)
        },

 

相关文章:

  • 2021-05-24
  • 2021-07-08
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-05-20
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案