- 新建组件:在component下新建一个tabBar

- 组件的index.wxml结构如下:
<cover-view class="tab-bar">
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{
{list}}" wx:key="index" class="tab-bar-item" data-path="{
{item.pagePath}}" data-index="{
{index}}" bindtap="tabChange">
<cover-image src="{
{tabbarIndex === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
<cover-view style="color: {
{tabbarIndex === index ? selectedColor : color}}">{
{item.text}}</cover-view>
</cover-view>
</cover-view>
- 组件的index.wxss结构如下: