现象描述
通过router.push接口跳转到快应用的B页面,当B页面只是引用一个自定义组件XX的时候,B页面的onShow生命周期无法触发。如下图所示:
问题代码如下。 B页面代码: <import name="listone" src="./aa.ux"></import>
<template>
<listone></listone>
</template>
<script>
import prompt from '@system.prompt'
export default {
private: {
},
onInit: function () {
},
onShow() {
console.log('The onShow event triggers');
prompt.showToast({
message: 'The onShow event triggers'
})
}, //无法触发
}
</script>
<style>
.demo-page {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
text-align: center;
}
</style> 自定义组件aa.ux代码: <template>
<div class="container">
<text>Nice day.</text>
<text>Nice day.</text>
<text>Nice day.</text>
<text>Nice day.</text>
</div>
</template>
<style>
.container {
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #D8D8D8;
}
</style>
<script>
module.exports = {
data: {
},
onInit() {
},
}
</script>
|