mounted() {
window.onresize = () => {
return (() => {
this.$nextTick(() => {
console.log('clientWidth', document.body.clientWidth);
console.log('clientHeight', document.body.clientHeight)
})
})()
}
},
Note: It is possible to monitor
in created
and , but if you monitor in created, the document has not been generated at this time. Please implement it according to your actual needs. Adding mounted
is also to ensure that the DOM has been loaded at this time.$nextTick()