uniapp 常用知识点

Posted 摸凹猫.

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uniapp 常用知识点相关的知识,希望对你有一定的参考价值。

1、原生导航栏(顶部)动态修改 title

uni.setNavigationBarTitle( title:"賬號名稱" )

2、原生导航栏(顶部)左边箭头默认是返回上一级,监听动态返回指定页面 与data()同级

// 监听原生导航栏的发回按钮
onBackPress(options) 
    if (options.from === \'navigateBack\') 
        return false;
    
    uni.switchTab(
        url: \'/pages/profile/index\'
    )
    return true;
    

 

uniapp常用配置

一、app打包后分离手机状态栏

 "app-plus" : {
        "statusbar" : {
            "immersed" : false
        }
}

二、表示忽略版本检查提示框,HBuilderX1.9.0及以上版本支持

"app-plus" : {
        "compatible" : {
            "ignoreVersion" : true  
        }
}

三、页面下拉刷新

{
	"path": "pages/index/index",
	"style": {
		"navigationBarTitleText": "首页",
		"enablePullDownRefresh":true
	}
}

四、底部导航配置

"tabBar": {
	"custom": true,
	"fontSize": "14px",
	"color": "#7A7E83",
	"selectedColor": "#58C1EF",
	"borderStyle": "black",
	"backgroundColor": "#ffffff",
	"list": [{
		"pagePath": "pages/index/index",
		"iconPath": "static/image/tab-bar-icon/shouy.png",
		"selectedIconPath": "static/image/tab-bar-icon/shouy_act.png",
		"text": "首页"
	}, {
		"pagePath": "pages/equipment/equipment",
		"iconPath": "static/image/tab-bar-icon/sheb.png",
		"selectedIconPath": "static/image/tab-bar-icon/sheb_act.png",
		"text": "设备"
	}, {
		"pagePath": "pages/personnel/personnel",
		"iconPath": "static/image/tab-bar-icon/reny.png",
		"selectedIconPath": "static/image/tab-bar-icon/reny_act.png",
		"text": "人员"
	}, {
		"pagePath": "pages/earnings/earnings",
		"iconPath": "static/image/tab-bar-icon/shoy.png",
		"selectedIconPath": "static/image/tab-bar-icon/shoy_act.png",
		"text": "收益"
	}]
}

五、开发环境与打包环境判断

let APP_SERVER_URL = ""

if(process.env.NODE_ENV === 'development'){
    // 开发环境
    // APP_SERVER_URL = 'http://192.168.0.5:8082'
    // APP_SERVER_URL = 'http://192.168.0.9:8082'
}else{
    // 生产环境
    APP_SERVER_URL = 'https://**.***.com/***/'
}

export default APP_SERVER_URL

六、去除uniapp原生导航

"globalStyle": {
	"navigationStyle": "custom",
	"app-plus": {
		"titleView": false
	}
}

七、改变原生导航字体颜色,背景

"globalStyle": {
	"navigationBarTextStyle": "black",
	"navigationBarTitleText": "uni-app",
	"navigationBarBackgroundColor": "#F8F8F8",
	"backgroundColor": "#f2f2f2"
}

以上是关于uniapp 常用知识点的主要内容,如果未能解决你的问题,请参考以下文章

uniapp内置API交互效果 - 常用方法汇总

uniapp常用配置

uniapp 常用原生插件大全

uniapp 常用原生插件大全

uniapp自用速查表 - 我的常用组件

uniapp自用速查表 - 我的常用组件