data () {
return {
screenwidth: document.body.clientWidth
}
},
mounted () {
window.onresize = () => {
return this.screenwidth = document.body.clientWidth
}
},
watch: {
screenwidth: {
immediate: true,
handler: function (val) {
console.log(val);
}
}
},
实时获取屏幕宽度
最新推荐文章于 2023-04-04 13:16:31 发布