微信小程序原生组件自定义Tabbar
创建tabbar代码文件
微信官网tabbar
在根目录下创建文件夹custom-tab-bar
及相关页面
custom-tab-bar/index.js
custom-tab-bar/index.json
custom-tab-bar/index.wxml
custom-tab-bar/index.wxss
custom-tab-bar
文件下的页面代码可参考官网示例代码
配置信息
- 在
app.json
中的tabBar
项指定custom
字段 - 与官网不同,我的所有tab页并非component构造器创建而是普通的页面所以不用在每个tab页的
json
里声明usingComponents
项
{
"pages": [
"pages/index/index",
"pages/video/index",
"pages/mine/index",
"pages/shop/index"
],
"tabBar": {
"custom": true,
"color": "#666",
"selectedColor": "#E5BA72",
"borderStyle": "black