当前位置:网站首页>uni-app 慕客热搜项目实战(一)tabBar的制作
uni-app 慕客热搜项目实战(一)tabBar的制作
2022-06-11 18:21:00 【小杰学前端】
项目完整效果展示:

在本文中我们要完成的就是底部导航栏 tabBar 的内容
1. 新建uni-app项目:
在模板里选择 uni-ui 项目
2. 在 pages 中新建三个页面对应我们要做的底部tabbar:
因为底部有三个选项所以我们要配置三个页面,三个页面都选择 scss 页面
这是对应的 pages 目录:

3. 配置 tabBar 的 pages.json 文件:
先删掉原有的 index 页面的配置,然后在 Pages 同级目录下创建 tabBar,配置方式同微信小程序的配置方式一样。首先我们配置 list,list 对应三个页面,每个页面对应一个内容:
pagePath是页面对应的路径, text 是 tabBar 对应文字,iconPath 是 tabBar 的字体图标路径, selectedIconPath 是选中状态下字体图标的路径
"tabBar": {
"list": [
{
"pagePath": "pages/hot/hot",
"text": "热搜",
"iconPath": "static/tab-icons/hot.png",
"selectedIconPath": "static/tab-icons/hot-active.png"
},
{
"pagePath": "pages/hot-video/hot-video",
"text": "热播",
"iconPath": "static/tab-icons/hot-video.png",
"selectedIconPath": "static/tab-icons/hot-video-active.png"
},
{
"pagePath": "pages/my/my",
"text": "我的",
"iconPath": "static/tab-icons/my.png",
"selectedIconPath": "static/tab-icons/my-active.png"
},
]
}当用户点击 tabBar 时,产生对应颜色的变化:

这样我们的 tabBar 就配置完成了。
4. 运行到小程序模拟器中查看效果:
5. 警告与错误处理
我们写完 tabBar 后,小程序工具的控制台会报一堆错误,下面我们就来处理一下:
5.1: 解决 sitemap 索引情况提示的警告问题:
微信小程序默认开启了索引功能,但是因为我们没有配置索引策略,导致出现了这么一个警告的问题,解决这个警告我们只需要关闭默认索引功能即可,双击打开 manifest.json,点击源码试图,添加 checkSiteMap 配置为 false 即可:

5.2:解决 Cannot read property 'forceUpdate' of undefined 的错误:
这个错误源于我们没有为项目配置 appID 的原因,所以只需要在 manifest 中完成 APPID 配置即可

边栏推荐
- 论高可用架构
- 2022-2023年西安交通大学管理学院MEM提前批面试网报通知
- Niuke brush questions part6
- 力扣33题,搜索旋转排序数组
- Force deduction 23 questions, merging K ascending linked lists
- Niu Ke's question -- finding the least common multiple
- 下载代码,并编译环境的问题
- Gmail:如何撤回发出的邮件?
- 5 minutes to understand the red, blue and purple in the attack and defense drill
- V-for loop traversal
猜你喜欢

Monitoring loss functions using visdom

VIM common commands
制造出静态坦克

Swagger2简单使用

非递归实现二叉树的前、中、后序遍历

Async leads to unexpected function results and changes the intention of the original code; await is only valid in async functions and the top level bodies of modules

Quanzhi Technology T3 Development Board (4 Core ARM Cortex - A7) - mqtt Communication Protocol case

Labelme for image data annotation
![[Golang]力扣Leetcode - 292. Nim 游戏(数学)](/img/82/54c3f6be9d08687b42cba0487380f0.png)
[Golang]力扣Leetcode - 292. Nim 游戏(数学)

Oracle高级数据库复习
随机推荐
On the problem that the while loop condition in keil does not hold but cannot jump out
[C语言]对一个数组的元素排序后平移元素
V-for loop traversal
全国院校MBA、EMBA、MPA、MEM、提前面试(预面试)时间批次已出(持续更新中)-文都管联院
[c language] shift elements after sorting elements of an array
牛客刷题——不要二
平衡搜索二叉树——AVL树
非递归实现二叉树的前、中、后序遍历
Force buckle 34 finds the first and last positions of elements in a sorted array
JS实现全屏展示的具体方法
力扣刷题——二叉树的层序遍历
H. 264 concept
[c language] output students' names and scores in descending order of scores with structures
Two methods for matlab to save imshow drawing pictures to a specified folder
v-for循环遍历
牛客刷题——part8
如何在 SAP BTP 上 手动执行 workflow
[C语言]用结构体把输入的指定分数范围内的学生输出
Niu Ke's questions -- binary search tree and bidirectional linked list
On the sequence traversal of binary tree