Uniapp开发总结

一、tabBar

如果应用是一个多 tab 应用,可以通过 tabBar 配置项指定一级导航栏,以及 tab 切换时显示的对应页。

pages.json 页面路由 | uni-app官网

pages.json基本配置:

复制代码
"tabBar": {
		"color": "#000",
		"selectedColor": "#4BB7DB",
		"borderStyle": "white",
		"fontSize": "14px",
		"list": [{
			"text": "预警",
			"pagePath": "pages/early_warning_list/early_warning_list",
			"iconPath": "./static/warning.png",
			"selectedIconPath": "./static/warning-selected.png"
		},
		{
			"text": "工单",
			"pagePath": "pages/work_order_list/work_order_list",
			"iconPath": "./static/work-order.png",
			"selectedIconPath": "./static/work-order-selected.png"
		},
		{
			"text": "监控",
			"pagePath": "pages/monitor/monitor",
			"iconPath": "./static/monitor.png",
			"selectedIconPath": "./static/monitor-selected.png"
		},
		{
			"text": "上报",
			"pagePath": "pages/data-report-list/data-report-list",
			"iconPath": "./static/data-report.png",
			"selectedIconPath": "./static/data-report-selected.png"
		},
		{
			"text": "我的",
			"pagePath": "pages/user/user",
			"iconPath": "./static/user.png",
			"selectedIconPath": "./static/user-selected.png"
		}]
	}

二、globalStyle

用于设置应用的状态栏、导航条、标题、窗口背景色等。

pages.json 页面路由 | uni-app官网

pages.json基本配置:

复制代码
	"globalStyle": {
		"navigationBarTextStyle": "black",
		"navigationBarTitleText": "XXX",
		"navigationBarBackgroundColor": "#D4ECFF",
		"backgroundColor": "#D4ECFF",
		"app-plus": {
			"bounce": "none" //关闭窗口回弹效果
		}
	}

三、跳转至tabBar页

uni.switchTab(OBJECT):

uni.navigateTo(OBJECT) | uni-app官网

跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。

复制代码
			uni.switchTab({
				url: '/pages/early_warning_list/early_warning_list',
				success: function() {
					console.log('跳转成功');
				},
				fail: function() {
					console.log('跳转失败');
				}
			});

四、关闭所有页面,打开到应用内的某个页面

uni.reLaunch(OBJECT)

uni.navigateTo(OBJECT) | uni-app官网

复制代码
		uni.reLaunch({
		    url: '/pages/login/login' // 这里的URL是登录页面的路径
		  });
相关推荐
爱怪笑的小杰杰12 小时前
uni-app Vue3 国际化最佳实践:告别应用重启,优雅实现多语言切换
前端·vue.js·uni-app
yqcoder12 小时前
uni-app 数据缓存详解
缓存·uni-app
2501_9159214313 小时前
穿越HTTPS迷雾:Wireshark中的TLS抓包秘诀与文件合并方法
网络协议·ios·小程序·https·uni-app·wireshark·iphone
小徐_233313 小时前
uni-app 组件库 Wot UI 2.0 发布了,我们带来了这些改变!
前端·微信小程序·uni-app
yqcoder15 小时前
uni-app 之 页面路由
uni-app
小离a_a15 小时前
uniapp小程序添加路由全局限制,增加路由白名单,登录后接口跳转参数正常传递
小程序·uni-app
游九尘19 小时前
uniapp获取定位uni.getLocation报错getLocation:fail maybe not obtain GPS Permission.
uni-app
雪芽蓝域zzs1 天前
uniapp 该应用与此设备的CPU不兼容
uni-app
CHB1 天前
uni-task - 轻量级团队任务管理系统
uni-app
行思理2 天前
UniApp 打包配置 iOS的UniversalLinks
uni-app·universal link