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_9159090612 小时前
iOS 反编译防护工具全景解析 从底层符号到资源层的多维安全体系
android·安全·ios·小程序·uni-app·iphone·webview
lvha13 小时前
uniapp BLE低功耗蓝牙插件 支持安卓 iOS 鸿蒙NEXT 微信小程序
uni-app·蓝牙
Redundantº18 小时前
Uniapp 适配安卓与 iOS 的 PDF、DOC 文件上传
android·ios·pdf·uni-app·webview
Harry技术19 小时前
UniApp H5 代理失效的终极替代方案
uni-app
2501_9159184121 小时前
iOS 应用如何防止破解?从逆向链路还原攻击者视角,构建完整的反破解工程实践体系
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_9160074721 小时前
iOS 压力测试的工程化体系 构建多工具协同的极限稳定性验证方案
android·ios·小程序·uni-app·压力测试·iphone·webview
2501_9160074721 小时前
iOS 应用上架流程的工程化拆解 从签名体系到提交审核的全过程管控
android·ios·小程序·https·uni-app·iphone·webview
一殊酒21 小时前
【前端开发】Uniapp:Android/IOS云打包
android·ios·uni-app
yqcoder21 小时前
uni-app 之 uni.showLoading
uni-app
2501_9159184121 小时前
构建可靠的 iOS 日志导出体系,从真机日志到系统行为的多工具协同实践
android·ios·小程序·https·uni-app·iphone·webview