uni-app 如何設置web-view 不全屏,不自動鋪滿,動態控制web-view的高度


var height=0;//定義動態的高度變量,如高度為定值,可以直接寫
uni.getSystemInfo({
//成功獲取的回調函數,返回值為系統信息
success: (sysinfo) => {
height = sysinfo.windowHeight-47;//自行修改,自己需要的高度
console.log(height);
},
complete: () => {
}
});
var currentWebview = this.$scope.$getAppWebview();//獲取當前web-view
setTimeout(function() {
var wv = currentWebview.children()[0];
console.log(wv);
wv.setStyle({//設置web-view距離頂部的距離以及自己的高度,單位為px
top: 68,
height:height
})
}, 1000);//如頁面初始化調用需要寫延遲


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM