uniapp 常用知识点
1、原生导航栏(顶部)动态修改 title
uni.setNavigationBarTitle({ title:"賬號名稱" })
2、原生导航栏(顶部)左边箭头默认是返回上一级,监听动态返回指定页面 与data()同级
// 监听原生导航栏的发回按钮 onBackPress(options) { if (options.from === 'navigateBack') { return false; } uni.switchTab({ url: '/pages/profile/index' }) return true; }
3、监听Android手机的返回键
onBackPress可与data、methods同级,或者在methods里面
onBackPress() {
uni.switchTab({
url:"/pages/index/index"
})
return true //必须返回 true 不然返回不到指定页面
}
4、清除应用app右上角的角标(收到信息的数字)
mounted() {
// #ifdef APP-PLUS
// 去除应用角标
// plus.push.clear()
plus.runtime.setBadgeNumber(0)
// #endif
}
5、设置margin或者padding后,页面内容还未满与页面可视高度出现的滚动条的解决方法
<style>
page{
background-color: #FAFBFE !important;
height: 100%;
display: flex;
flex-direction: column;
}
</style>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通