本篇內(nèi)容主要講解“vue怎么獲取屏幕的寬度”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實(shí)用性強(qiáng)。下面就讓小編來帶大家學(xué)習(xí)“vue怎么獲取屏幕的寬度”吧!
創(chuàng)新互聯(lián)建站專注于勉縣網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠為您提供勉縣營銷型網(wǎng)站建設(shè),勉縣網(wǎng)站制作、勉縣網(wǎng)頁設(shè)計(jì)、勉縣網(wǎng)站官網(wǎng)定制、微信平臺小程序開發(fā)服務(wù),打造勉縣網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供勉縣網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
具體方法如下:
1.使用document.documentElement方法獲取屏幕的寬高
windowWidth: document.documentElement.clientWidth, //獲取屏幕寬度
windowHeight: document.documentElement.clientHeight, //獲取屏幕高度
2.在watch中實(shí)時(shí)監(jiān)聽屏幕寬高
watch: {
windowHeight (val) {
let that = this;
console.log("實(shí)時(shí)屏幕高度:",val, that.windowHeight );
},
windowWidth (val) {
let that = this;
console.log("實(shí)時(shí)屏幕寬度:",val, that.windowHeight );
}
},
3.使用mounted函數(shù)獲取屏幕寬高
mounted() {
var that = this;
window.onresize = () => {
return (() => {
window.fullHeight = document.documentElement.clientHeight;
window.fullWidth = document.documentElement.clientWidth;
that.windowHeight = window.fullHeight; //獲取屏幕高度
that.windowWidth = window.fullWidth; //獲取屏幕寬度
})()
};
},
到此,相信大家對“vue怎么獲取屏幕的寬度”有了更深的了解,不妨來實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
網(wǎng)頁名稱:vue怎么獲取屏幕的寬度
文章起源:http://chinadenli.net/article16/joijgg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、品牌網(wǎng)站建設(shè)、搜索引擎優(yōu)化、手機(jī)網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)