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>

 

 

 



 

posted @ 2023-05-31 11:47  多喝热水,早点睡觉  阅读(73)  评论(0编辑  收藏  举报