index.vue
<template>
<custom-cmp></custom-cmp>
</template>
<script setup>
// 此处不要注册生命周期钩子
</script>
custom-cmp.vue
<template>
<view>custom component</view>
</template>
<script>
export default {
name: "custom-cmp",
onShow() {
console.log('pageShow', +new Date())
},
onPageShow() {
console.log(this);
console.log('onPageShow', +new Date())
},
}
</script>
<script setup>
import { onShow } from '@dcloudio/uni-app'
onShow(() => console.log('setupOnShow', +new Date()))
</script>