vue监听浏览器窗口的变化
mounted() {const that = thiswindow.onresize = () => {return (() => {window.screenWidth = window.innerWidththis.screenWidth = window.screenWidth})()...
·
mounted() {
const that = this
window.onresize = () => {
return (() => {
window.screenWidth = window.innerWidth
this.screenWidth = window.screenWidth
})()
}
}
watch: {
// 监听浏览器窗口宽度,当浏览器窗口小于1325时,隐藏系统时间
screenWidth(val) {
if (val < 1325) {
this.$store.dispatch('handleHideSystemTime')
} else {
this.$store.dispatch('handleShowSystemTime')
}
}
},
更多推荐
已为社区贡献16条内容
所有评论(0)