App.ku.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import FgTabbar from '@/tabbar/index.vue'
  4. import { isPageTabbar, tabbarStore } from './tabbar/store'
  5. import { currRoute } from './utils'
  6. const isCurrentPageTabbar = ref(true)
  7. onShow(() => {
  8. console.log('App.ku.vue onShow', currRoute())
  9. const { path } = currRoute()
  10. // “蜡笔小开心”提到本地是 '/pages/index/index',线上是 '/' 导致线上 tabbar 不见了
  11. // 所以这里需要判断一下,如果是 '/' 就当做首页,也要显示 tabbar
  12. isCurrentPageTabbar.value = path === '/' || isPageTabbar(path)
  13. if (isCurrentPageTabbar.value) {
  14. tabbarStore.setAutoCurIdx(path)
  15. }
  16. })
  17. const helloKuRoot = ref('Hello AppKuVue')
  18. const exposeRef = ref('this is form app.Ku.vue')
  19. defineExpose({
  20. exposeRef,
  21. })
  22. </script>
  23. <template>
  24. <view>
  25. <!-- 这个先隐藏了,知道这样用就行 -->
  26. <!-- <view class="hidden text-center">
  27. {{ helloKuRoot }},这里可以配置全局的东西
  28. </view> -->
  29. <KuRootView />
  30. <FgTabbar v-if="isCurrentPageTabbar" />
  31. </view>
  32. </template>