computed: {
// 页面宽度
width() {
if (process.client) {
const { height, width } = window.screen;
return width
}
return null;
},
},
nuxt.js获取页面宽度 高度
该篇文章介绍了如何在前端使用computed属性动态获取浏览器窗口的宽度,特别针对客户端环境(浏览器)进行了优化。
摘要由CSDN通过智能技术生成