mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-02 15:11:15 +08:00
修复bug ,底部导航,装修优化
This commit is contained in:
@@ -1,21 +1,30 @@
|
||||
<template>
|
||||
<u-tabbar v-bind="tabbarStyle" :list="tabbarList" @change="handleChange"></u-tabbar>
|
||||
<u-tabbar
|
||||
v-model="current"
|
||||
v-bind="tabbarStyle"
|
||||
:list="tabbarList"
|
||||
@change="handleChange"
|
||||
:hide-tab-bar="false"
|
||||
></u-tabbar>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { currentPage, navigateTo } from '@/utils/util'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { navigateTo } from '@/utils/util'
|
||||
import { computed, ref } from 'vue'
|
||||
const current = ref()
|
||||
const appStore = useAppStore()
|
||||
const tabbarList = computed(() => {
|
||||
return appStore.getTabbarConfig.map((item: any) => ({
|
||||
iconPath: item.unselected,
|
||||
selectedIconPath: item.selected,
|
||||
text: item.name,
|
||||
link: JSON.parse(item.link),
|
||||
pagePath: JSON.parse(item.link).path
|
||||
}))
|
||||
return appStore.getTabbarConfig.map((item: any) => {
|
||||
const link = JSON.parse(item.link)
|
||||
return {
|
||||
iconPath: item.unselected,
|
||||
selectedIconPath: item.selected,
|
||||
text: item.name,
|
||||
link,
|
||||
pagePath: link.path
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const tabbarStyle = computed(() => ({
|
||||
@@ -26,8 +35,4 @@ const handleChange = (index: number) => {
|
||||
const selectTab = tabbarList.value[index]
|
||||
navigateTo(selectTab.link, 'reLaunch')
|
||||
}
|
||||
// onMounted(() => {
|
||||
// const page = currentPage()
|
||||
// console.log(page)
|
||||
// })
|
||||
</script>
|
||||
|
||||
@@ -238,16 +238,20 @@ export default {
|
||||
},
|
||||
// 切换tab
|
||||
switchTab(index) {
|
||||
// 发出事件和修改v-model绑定的值
|
||||
this.$emit("change", index);
|
||||
|
||||
let pagePath = this.list[index].pagePath;
|
||||
// 如果有配置pagePath属性,使用uni.switchTab进行跳转
|
||||
if (this.list[index].pagePath) {
|
||||
if (pagePath) {
|
||||
if(pagePath == this.pageUrl || pagePath == "/" + this.pageUrl) return
|
||||
// 发出事件和修改v-model绑定的值
|
||||
this.$emit("change", index);
|
||||
uni.switchTab({
|
||||
url: this.list[index].pagePath
|
||||
url: pagePath
|
||||
});
|
||||
} else {
|
||||
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
|
||||
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
|
||||
this.$emit("change", index);
|
||||
this.$emit("input", index);
|
||||
this.$emit("update:modelValue", index);
|
||||
}
|
||||
@@ -370,4 +374,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -53,15 +53,8 @@ export enum LinkTypeEnum {
|
||||
}
|
||||
|
||||
export function navigateTo(link: Link, navigateType: 'navigateTo' | 'reLaunch' = 'navigateTo') {
|
||||
let url: string
|
||||
switch (link.type) {
|
||||
case LinkTypeEnum.SHOP_PAGES:
|
||||
url = link.query ? `${link.path}?${objectToQuery(link.query)}` : link.path
|
||||
uni[navigateType]({ url })
|
||||
break
|
||||
case LinkTypeEnum.CUSTOM_LINK:
|
||||
uni[navigateType]({ url: `/pages/webview/webview?url=${link.path}` })
|
||||
}
|
||||
const url = link.query ? `${link.path}?${objectToQuery(link.query)}` : link.path
|
||||
uni[navigateType]({ url })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user