Vue监听屏幕宽度
data() {return {fullWidth: document.documentElement.clientWidth}},mounted() {//const that = thiswindow.onresize = () => {return (() =&...
data() {
return {
fullWidth: document.documentElement.clientWidth
}
},
mounted() {
//
const that = this
window.onresize = () => {
return (() => {
window.fullWidth = document.documentElement.clientWidth
that.fullWidth = window.fullWidth
})()
}
},
watch: {
/* 监听*/
fullWidth(val) {
if (!this.timer) {
this.fullWidth = val
this.timer = true
let that = this
setTimeout(function() {
that.timer = false
console.log("11")
}, 400)
}
}
}
更多推荐
所有评论(0)