//查看div的宽度export default {
data() {
return {
datas: {},
fullWidth: document.documentElement.clientHeight,
DivWidth: 0
};
},
watch: {
fullWidth(val) {
//监控浏览器宽度变化
if (!this.timer) {
this.fullWidth = val;
this.timer = true;
let that = this;
setTimeout(function () {
that.timer = false;
}, 400);
}
// console.log(this.fullWidth);
}
},
methods: {
get_bodyWidth() {
//动态获取浏览器宽度
const that = this;
window.onresize = () => {
return (() => {
window.fullWidth = document.documentElement.clientWidth;
that.fullWidth = window.fullWidth;
})();
};
},
//获取div的宽度
getDivWidth() {
let me = this;
this.DivWidth = me.$refs.companyStyle.offsetWidth;
console.log(this.DivWidth);
}
},
mounted() {
this.get_bodyWidth();
// this.getDivWidth();
},
},
————————————————
版权声明:本文为CSDN博主「@曾经@」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_41628411/article/details/90475954
网友评论