123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <view>
- <u-tabbar :value="activeValue" @change="changeTabbar" :fixed="true" :placeholder="true"
- :safeAreaInsetBottom="true">
- <u-tabbar-item :text="item.text" :name="item.name" v-for="(item, index) in list" :key="index">
- <image class="icon" slot="active-icon" :src="item.selectedIconPath"></image>
- <image class="icon" slot="inactive-icon" :src="item.iconPath"></image>
- </u-tabbar-item>
- </u-tabbar>
- </view>
- </template>
- <script>
- const app = getApp()
- export default {
- name: "custom-tab-bar",
- props: {
- activeValue: {
- type: [Number, String],
- default: 'index'
- },
- },
- data() {
- return {
- list: []
- };
- },
- mounted() {
- this.tabList()
- },
- methods: {
- changeTabbar(e) {
- console.log(e);
- if (e == 'index') {
- uni.switchTab({
- url: '/pages/index/index'
- })
- } else if (e == 'core') {
- uni.switchTab({
- url: '/pages/core/index'
- })
- } else if (e == 'user') {
- uni.switchTab({
- url: '/pages/user/index'
- })
- }
- },
- tabList() {
- this.list = [{
- name: "index",
- iconPath: "../../static/tabbar/index.png",
- selectedIconPath: "../../static/tabbar/index_select.png",
- text: "刮奖"
- },
- {
- name: "core",
- iconPath: "../../static/tabbar/law.png",
- selectedIconPath: "../../static/tabbar/law_select.png",
- text: "兑换大厅"
- },
- {
- name: "user",
- iconPath: "../../static/tabbar/user.png",
- selectedIconPath: "../../static/tabbar/user_select.png",
- text: "我的"
- }
- ]
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .icon {
- width: 54rpx;
- height: 54rpx;
- }
- </style>
|