#窗口样式相关的 API
uni.getTopWindowStyle()
获取 topWindow 的样式
uni.getLeftWindowStyle()
获取 leftWindow 的样式
uni.getRightWindowStyle()
获取 rightWindow 的样式
uni.setTopWindowStyle(OBJECT)
设置 topWindow 的样式 ,参数说明
css 样式对象,需写驼峰css属性 ,{height: '100px', backgroundColor: 'red'}
uni.setLeftWindowStyle(OBJECT)
设置 leftWindow 的样式
uni.setRightWindowStyle(OBJECT)
设置 rightWindow 的样式
字体
uni.loadFontFace(Object object)
动态加载网络字体,文件地址需为下载类型。微信小程序 '2.10.0'
起支持全局生效,需在 app.vue
中调用。
uni.loadFontFace({family: 'Bitstream Vera Serif Bold',source: 'url("https://sungd.github.io/Pacifico.ttf")',success() {console.log('success')}
})
uni.upx2px()
将rpx单位值转换成px
下拉刷新
onPullDownRefresh -97
在 js 中定义 onPullDownRefresh 处理函数(和onLoad等生命周期函数同级),监听该页面用户下拉刷新事件。
- 需要在
pages.json
里,找到的当前页面的pages节点,并在style
选项中开启enablePullDownRefresh
。 - 当处理完数据刷新后,
uni.stopPullDownRefresh
可以停止当前页面的下拉刷新。
uni.startPullDownRefresh(OBJECT) -3
主动下拉刷新
开始下拉刷新,调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。
uni.stopPullDownRefresh() -104
停止当前页面下拉刷新。
{"pages": [{"path": "pages/index/index","style": {"navigationBarTitleText": "uni-app","enablePullDownRefresh": true}}],"globalStyle": {"navigationBarTextStyle": "white","navigationBarBackgroundColor": "#0faeff","backgroundColor": "#fbf9fe"}
}
// 仅做示例,实际开发中延时根据需求来使用。
export default {data() {return {text: 'uni-app'}},onLoad: function (options) {setTimeout(function () {console.log('start pulldown');}, 1000);uni.startPullDownRefresh();},onPullDownRefresh() {console.log('refresh');setTimeout(function () {uni.stopPullDownRefresh();}, 1000);}
}