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是登录页面的路径
		  });
相关推荐
2501_9160088912 小时前
iOS开发APP上架全流程解析:从开发到App Store的完整指南
android·ios·小程序·https·uni-app·iphone·webview
酷酷的鱼13 小时前
2026 跨平台开发终极选型:Flutter, React Native 与 uni-app x 深度博标与规划指南
flutter·react native·uni-app
biyezuopinvip13 小时前
基于uni-app和Express的问答对战小程序的设计与实现(论文)
小程序·uni-app·毕业设计·论文·express·毕业论文·问答对战小程序的设计与实现
2501_915909061 天前
Charles 抓不到包怎么办?iOS 调试过程中如何判断请求路径
android·ios·小程序·https·uni-app·iphone·webview
2501_916007471 天前
iOS和iPadOS文件管理系统全面解析与使用指南
android·ios·小程序·https·uni-app·iphone·webview
卜锦元1 天前
EchoChat搭建自己的音视频会议系统01-准备工作
c++·golang·uni-app·node.js·音视频
敲敲了个代码1 天前
让 Vant 弹出层适配 Uniapp Webview 返回键
前端·javascript·vue.js·学习·面试·uni-app
2501_915921431 天前
iOS App 开发阶段性能优化,观察 CPU、内存和日志变化
android·ios·性能优化·小程序·uni-app·iphone·webview
木子啊1 天前
UNIAPP国内房贷计算器
uni-app·房贷·房贷计算器·房贷利率·公积金贷款·商业贷款
游戏开发爱好者82 天前
在 iOS 开发、测试与上架过程中 如何做证书管理
android·ios·小程序·https·uni-app·iphone·webview