<el-col :span="7" ref="wrap"><div></div></el-col>
mounted () { let height =document.body.clientHeight
console.log(height)
console.log(this.$refs.wrap)
// this.$refs.wrap.style.height = height
}輸出的this.$refs.wrap,并不是一個(gè)dom,不知是哪里出了問(wèn)題?
2 回答

智慧大石
TA貢獻(xiàn)1946條經(jīng)驗(yàn) 獲得超3個(gè)贊
$refs.wrap 拿到的是一個(gè)VUE組件,并不是一個(gè)DOM。
如果想要手動(dòng)操作DOM,在組件內(nèi)給節(jié)點(diǎn)一個(gè)ID,比如el-col上給一個(gè)ID,然后用this.$el.querySelector(#ID)拿到來(lái)進(jìn)行操作。
添加回答
舉報(bào)
0/150
提交
取消