feat(布局): 在tabbar组件中暴露testUniLayoutExposedData变量
在about页面通过onReady钩子获取暴露的变量,解决onLoad钩子无法获取的问题
This commit is contained in:
@@ -7,6 +7,10 @@ const themeVars: ConfigProviderThemeVars = {
|
||||
// buttonPrimaryBgColor: '#07c160',
|
||||
// buttonPrimaryColor: '#07c160',
|
||||
}
|
||||
const testUniLayoutExposedData = ref('testUniLayoutExposedData')
|
||||
defineExpose({
|
||||
testUniLayoutExposedData,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user