uni-app(1)pages. json和tabBar

第一步 在HBuilderX中新建项目

填写项目名称、确定目录、选择模板、选择Vue版本:3、点击创建

第二步 配置pages.json文件

pages.json是一个非常重要的配置文件,它用于配置小程序的页面路径、窗口表现、导航条样式等信息。

右键点击pages,按照如下操作

效果如下图:

my.vue文件代码:

复制代码
<template>
	<view>
		页面内容
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			
		}
	}
</script>

<style>

</style>

第三步 在pages.json文件中配置tabBar

复制代码
{
	"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
		{
			"path": "pages/index/index",
			"style": {
				"navigationBarTitleText": "首页"
			}
		},
		{
			"path" : "pages/my/my",
			"style" : 
			{
				"navigationBarTitleText" : "我的"
			}
		}
	],
	"globalStyle": {
		"navigationBarTextStyle": "white",//修改首页上方文字颜色
		"navigationBarTitleText": "首页",
		"navigationBarBackgroundColor": "#27BA9B",//修改首页的背景颜色
		"backgroundColor": "#F8F8F8"
	},
	"tabBar": {
		"selectedColor": "#27BA9B",
		"list": [
			{
				"pagePath": "pages/index/index",
				"text": "首页",
				"iconPath": "static/logo.png",
				"selectedIconPath": "static/logo.png"
			},
			{
				"pagePath": "pages/my/my",
				"text": "我的",
				"iconPath": "static/logo.png",
				"selectedIconPath": "static/logo.png"
			}
		]
	},
	"uniIdRouter": {}
}

最后进行预览,如图所示:

相关推荐
码兄科技19 小时前
24小时自助健身房系统软件开发实战指南:功能设计与部署方案
java·spring boot·uni-app
2501_9160074720 小时前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
2501_916008891 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
2501_916008891 天前
怎么用 Godot 导出 iOS 应用并上架 App Store?签名字段该填什么?
android·ios·小程序·https·uni-app·iphone·webview
郑州光合科技余经理2 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
白远山2 天前
城市电竞陪玩调度系统实战:从派单算法到多端协同的架构拆解
java·架构·uni-app·需求分析
白远山3 天前
上海24小时自助健身房系统软件开发实战指南
java·架构·uni-app·需求分析
白远山4 天前
上海24小时自助健身房系统软件开发实战指南:从需求到部署
java·架构·uni-app·需求分析
海鸥两三4 天前
小程序文档预览 · 进阶面试题
小程序·uni-app·uniapp
海鸥两三4 天前
微信小程序 PDF 预览实践(uni.downloadFile → uni.openDocument)
小程序·uni-app