48 lines
1.1 KiB
JavaScript
48 lines
1.1 KiB
JavaScript
// components/custom-tabbar/index.js
|
|
Component({
|
|
properties: {
|
|
cartCount: {
|
|
type: Number,
|
|
value: 0,
|
|
},
|
|
},
|
|
|
|
data: {
|
|
list: [
|
|
{
|
|
pagePath: "/pages/home/home",
|
|
iconPath: "/images/tab/home.png",
|
|
selectedIconPath: "/images/tab/home-active.png",
|
|
text: "首页",
|
|
},
|
|
{
|
|
pagePath: "/pages/category/category",
|
|
iconPath: "/images/tab/category.png",
|
|
selectedIconPath: "/images/tab/category-active.png",
|
|
text: "分类",
|
|
},
|
|
{
|
|
pagePath: "/pages/cart/cart",
|
|
iconPath: "/images/tab/cart.png",
|
|
selectedIconPath: "/images/tab/cart-active.png",
|
|
text: "购物车",
|
|
},
|
|
{
|
|
pagePath: "/pages/user/user",
|
|
iconPath: "/images/tab/user.png",
|
|
selectedIconPath: "/images/tab/user-active.png",
|
|
text: "我的",
|
|
},
|
|
],
|
|
active: 0,
|
|
},
|
|
|
|
methods: {
|
|
switchTab(e) {
|
|
const { path, index } = e.currentTarget.dataset;
|
|
this.setData({ active: index });
|
|
wx.switchTab({ url: path });
|
|
},
|
|
},
|
|
});
|