初始化
This commit is contained in:
38
custom-tab-bar/index.js
Normal file
38
custom-tab-bar/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// custom-tab-bar/index.js
|
||||
Component({
|
||||
lifetimes: {
|
||||
attached: function () {
|
||||
this.getTabBar(tabBar => {
|
||||
let value = tabBar.data.selected
|
||||
this.setData({
|
||||
selected: value
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
},
|
||||
data: {
|
||||
selected: '',
|
||||
tabList: [
|
||||
{
|
||||
path: "/pages/home/index",
|
||||
label: '首页',
|
||||
icon: 'home'
|
||||
},
|
||||
{
|
||||
path: "/pages/expert/index",
|
||||
label: '专家服务',
|
||||
icon: 'call-1'
|
||||
}
|
||||
]
|
||||
},
|
||||
methods: {
|
||||
switchTab(e) {
|
||||
let value = e.detail.value
|
||||
let info = this.data.tabList.find(item => item.label == value)
|
||||
if (info) {
|
||||
wx.switchTab({ url: info.path })
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
4
custom-tab-bar/index.json
Normal file
4
custom-tab-bar/index.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
5
custom-tab-bar/index.scss
Normal file
5
custom-tab-bar/index.scss
Normal file
@@ -0,0 +1,5 @@
|
||||
.t-tab-bar {
|
||||
box-shadow: 4px 4px 20px rgba(0, 0, 0, 0.15);
|
||||
--td-tab-bar-active-color: rgba(0, 106, 106, 1);
|
||||
--td-tab-bar-color: rgba(151, 151, 151, 1);
|
||||
}
|
||||
12
custom-tab-bar/index.wxml
Normal file
12
custom-tab-bar/index.wxml
Normal file
@@ -0,0 +1,12 @@
|
||||
<t-tab-bar t-class="t-tab-bar"
|
||||
defaultValue="label1"
|
||||
value="{{selected}}"
|
||||
bindchange="switchTab"
|
||||
split="{{false}}">
|
||||
<t-tab-bar-item value="{{item.label}}"
|
||||
icon="{{item.icon}}"
|
||||
wx:for="{{tabList}}"
|
||||
wx:key="index">
|
||||
{{item.label}}
|
||||
</t-tab-bar-item>
|
||||
</t-tab-bar>
|
||||
Reference in New Issue
Block a user