VUE監聽resize
阿新 • • 發佈:2020-12-23
技術標籤:解析度相容的精益求精VUE
data () {
return {
windowHeight: window.innerHeight
}
}
mounted () {
window.onresize = () => {
this.windowHeight = window.innerHeight
}
}
watch: {
'windowHeight': function (newVal, oldVal) { //監聽螢幕寬度變化
this.windowHeight = newVal
console. log(newVal)
}
}