feat: 添加@uni-ku/root依赖并配置vite插件
移除页面中的tabbar布局配置 在default.vue中暴露testUniLayoutExposedData 添加App.ku.vue作为根组件 更新pages.json移除tabbar布局配置
This commit is contained in:
24
src/App.ku.vue
Normal file
24
src/App.ku.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import FgTabbar from '@/tabbar/index.vue'
|
||||
import { isPageTabbar } from './tabbar/store'
|
||||
import { currRoute } from './utils'
|
||||
|
||||
const isCurrentPageTabbar = ref(true)
|
||||
onShow(() => {
|
||||
console.log('App.ku.vue onShow', currRoute())
|
||||
const { path } = currRoute()
|
||||
isCurrentPageTabbar.value = isPageTabbar(path)
|
||||
})
|
||||
|
||||
const helloKuRoot = ref('Hello AppKuVue')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="text-center">
|
||||
{{ helloKuRoot }},这里可以配置全局的东西
|
||||
</view>
|
||||
<!-- 顶级 KuRootView -->
|
||||
<KuRootView />
|
||||
<FgTabbar v-if="isCurrentPageTabbar" />
|
||||
</template>
|
||||
@@ -2,6 +2,11 @@
|
||||
import { useThemeStore } from '@/store'
|
||||
|
||||
const themeStore = useThemeStore()
|
||||
|
||||
const testUniLayoutExposedData = ref('testUniLayoutExposedData')
|
||||
defineExpose({
|
||||
testUniLayoutExposedData,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
{
|
||||
"path": "pages/index/index",
|
||||
"type": "home",
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTitleText": "首页"
|
||||
@@ -52,7 +51,6 @@
|
||||
{
|
||||
"path": "pages/about/about",
|
||||
"type": "page",
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关于"
|
||||
}
|
||||
@@ -92,7 +90,6 @@
|
||||
{
|
||||
"path": "pages/me/me",
|
||||
"type": "page",
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<route lang="jsonc" type="page">
|
||||
{
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关于"
|
||||
}
|
||||
@@ -49,6 +48,11 @@ onReady(() => {
|
||||
console.log('onReady:', uniLayout.value) // onReady: Proxy(Object)
|
||||
console.log('onReady:', uniLayout.value.testUniLayoutExposedData) // onReady: testUniLayoutExposedData
|
||||
})
|
||||
// 结论:第一次通过onShow获取不到,但是可以通过 onReady获取到,后面就可以通过onShow获取到了
|
||||
onShow(() => {
|
||||
console.log('onShow:', uniLayout.value) // onReady: Proxy(Object)
|
||||
console.log('onShow:', uniLayout.value?.testUniLayoutExposedData) // onReady: testUniLayoutExposedData
|
||||
})
|
||||
|
||||
function gotoTabbar() {
|
||||
uni.switchTab({
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page -->
|
||||
<route lang="jsonc" type="home">
|
||||
{
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
// 'custom' 表示开启自定义导航栏,默认 'default'
|
||||
"navigationStyle": "custom",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<route lang="jsonc" type="page">
|
||||
{
|
||||
"layout": "tabbar",
|
||||
"style": {
|
||||
// 'custom' 表示开启自定义导航栏,默认 'default'
|
||||
// "navigationStyle": "custom",
|
||||
|
||||
Reference in New Issue
Block a user