feat(布局): 在tabbar组件中暴露testUniLayoutExposedData变量

在about页面通过onReady钩子获取暴露的变量,解决onLoad钩子无法获取的问题
This commit is contained in:
feige996
2025-08-11 16:13:08 +08:00
parent 914a2b04b7
commit 91f31839b7
2 changed files with 13 additions and 0 deletions

View File

@@ -7,6 +7,10 @@ const themeVars: ConfigProviderThemeVars = {
// buttonPrimaryBgColor: '#07c160',
// buttonPrimaryColor: '#07c160',
}
const testUniLayoutExposedData = ref('testUniLayoutExposedData')
defineExpose({
testUniLayoutExposedData,
})
</script>
<template>

View File

@@ -32,6 +32,15 @@ function gotoSubPage() {
url: '/pages-sub/demo/index',
})
}
// uniLayout里面的变量通过 expose 暴露出来后可以在 onReady 钩子获取到onLoad 钩子不行)
const uniLayout = ref()
onLoad(() => {
console.log('onLoad:', uniLayout.value) // onLoad: undefined
})
onReady(() => {
console.log('onReady:', uniLayout.value) // onReady: Proxy(Object)
console.log('onReady:', uniLayout.value.testUniLayoutExposedData) // onReady: testUniLayoutExposedData
})
</script>
<template>