- 如何隐藏scroll-view组件滚动条
解决:给scroll-view组件的父组件上加上以下css即可
::-webkit-scrollbar{
display: none;
width: 0;
height: 0;
color: transparent;
background: transparent;
}
- css获取状态栏高度
解决:css动态获取
var(--status-bar-height);
3.如何动态获取(设置)uniapp内view高度
解决:在onReady内动态获取(计算)
onReady() {
// 调整内容区域高度
uni.getSystemInfo({
success: (res) => {
let info = uni.createSelectorQuery().select('.footer');
// console.log(info);
info.boundingClientRect((data)=>{
let height = res.windowHeight - data.height
this.contentHeight = height;
}).exec();
}
});
}
4.如何动态设置顶部按钮文字
解决:见如下代码
// 动态修改顶部按钮文字
// 传入要修改的目标文字
changeBtnName(str){
var pages = getCurrentPages();
var page = pages[pages.length - 1];
var currentWebview = page.$getAppWebview();
var tn = currentWebview.getStyle().titleNView;
// console.log(tn);
tn.buttons[0].text = str;
currentWebview.setStyle({
titleNView: tn
});
}
- 固定屏幕竖直方向
解决:App.vue的onLaunch方法内加入以下代码
plus.screen.lockOrientation('portrait-primary'); //锁定屏幕
6.app页面transparent类型下顶部站位
template标签内:
<!--设置view占用通知栏-->
<view class="titleNview-placing"></view>
CSS
.titleNview-placing {
height: var(--status-bar-height);
padding-top: 44px;
box-sizing: content-box;
}
7.app底部安全距离设置
.cloud-footer-section {
width: 750upx;
height: 100upx;
border-top: solid 1upx #f6f6f6;
position: fixed;
bottom: 0;
left: 0;
background-color: #FFFFFF;
bottom: constant(safe-area-inset-bottom);
bottom: env(safe-area-inset-bottom);
}
网友评论