系统时间的定位,应该根据显示器的分别率可以适配
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
9b9c83797a
commit
5a8e1e5af7
|
|
@ -9,13 +9,28 @@ export default {
|
|||
return {
|
||||
time: '',
|
||||
timer: null,
|
||||
suggestionTextColor: '#909399'
|
||||
suggestionTextColor: '#909399',
|
||||
resizeObserver: null
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTime()
|
||||
},
|
||||
async mounted() {
|
||||
this.resizeObserver = new ResizeObserver(entries => {
|
||||
entries.forEach(entry => {
|
||||
// 获取元素的新尺寸
|
||||
// const { width, height } = entry.contentRect;
|
||||
// console.log(`元素宽度:${width}px, 高度:${height}px`);
|
||||
// 在此可以将宽高值保存到 data 中
|
||||
// this.elementWidth = width;
|
||||
// this.elementHeight = height;
|
||||
this.dragDoc()
|
||||
});
|
||||
});
|
||||
const body = document.getElementsByTagName('body')[0]
|
||||
// 开始监听指定元素
|
||||
this.resizeObserver.observe(body);
|
||||
this.dragDoc()
|
||||
this.setColor()
|
||||
},
|
||||
|
|
@ -102,6 +117,9 @@ export default {
|
|||
clearInterval(this.timer)
|
||||
this.timer = null
|
||||
}
|
||||
if (this.resizeObserver) {
|
||||
this.resizeObserver.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue