成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

vue移動(dòng)端彈起蒙層滑動(dòng)禁止底部滑動(dòng)操作

瀏覽:54日期:2022-12-30 18:43:22

解決辦法

在蒙層彈起的時(shí)候?qū)ody設(shè)置為fixed定位

在蒙層消失的時(shí)候?qū)ody恢復(fù)原位

popupVisible(newValue) { if (newValue) { document.body.style.position = ’fixed’; document.body.style.width = ’100%’; document.body.style.height = ’100%’; } else { document.body.style.position = ’static’; document.body.style.height = ’auto’; }},

設(shè)置為fixed的時(shí)候整個(gè)頁面會恢復(fù)原位,如果需要把位置開始scrollY記下來,恢復(fù)的時(shí)候在滾到原來的位置

popupVisible(newValue) { if (newValue) { document.body.style.position = ’fixed’; document.body.style.width = ’100%’; document.body.style.height = ’100%’; this.top = window.scrollY; } else { document.body.style.position = ’static’; document.body.style.height = ’auto’; window.scrollTo(0, this.top); }}

補(bǔ)充知識:解決使用vue時(shí)頁面內(nèi)有彈窗時(shí)禁止頁面滾動(dòng) 以及頁面內(nèi)彈窗因絕對定位導(dǎo)致頁面壓縮的問題

如下所示:

@touchmove.prevent

當(dāng)頁面彈窗出現(xiàn)時(shí)設(shè)置 @touchmove.prevent = 'false';

2.頁面內(nèi)彈窗因絕對定位導(dǎo)致頁面壓縮的問題 造成底部導(dǎo)航欄固定在輸入鍵盤上面的問題

// 動(dòng)態(tài)設(shè)置背景圖的高度為瀏覽器可視區(qū)域高度// 首先在Virtual DOM渲染數(shù)據(jù)時(shí),設(shè)置下背景圖的高度. this.bodyHeight = `${document.documentElement.clientHeight}`;// 然后監(jiān)聽window的resize事件.在瀏覽器窗口變化時(shí)再設(shè)置下背景圖高度. window.onresize = function temp() { var bodyHeight = `${document.documentElement.clientHeight}`; that.bodyHeight = bodyHeight; };

通過判斷 bodyHeight 數(shù)值的變化,來控制底部導(dǎo)航欄的出現(xiàn)與隱藏

以上這篇vue移動(dòng)端彈起蒙層滑動(dòng)禁止底部滑動(dòng)操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章: