1.生命周期
页面A的生命周期接口的调用顺序
- 打开页面A:onInit() -> onReady() -> onShow()
- 在页面A打开页面B:onHide()
- 从页面B返回页面A:onShow()
- 退出页面A:onBackPress() -> onHide() -> onDestroy()
- 页面隐藏到后台运行:onInactive() -> onHide()
- 页面从后台运行恢复到前台:onShow() -> onActive()
2.案例
cookbook相关代码
<element name= "cb-swiper" src="./swiper/swiper"></element>
<element name= "cb-hotcate" src="./hotcate/hotcate"></element>
<div class= "cb-container">
<div class="cb-title">
<text>美食大全</text>
</div>
<div class="cb-body">
<list>
<list-item class="cb-body-item">
<cb-swiper list="{{list}}"></cb-swiper>
</list-item>
<list-item class="cb-body-item">
<cb-hotcate></cb-hotcate>
</list-item>
</list>
</div>
</div>
.cb-container {
flex-direction: column ;
}
.cb-body {
flex: 1;
}
.cb-body-item{
flex-direction: column;
}
.cb-title {
width: 100%;
height: 44px;
justify-content: center;
align-items: center;
background-color: #ee742f;
}
text{
font-size: 16px;
font-weight: normal;
color:#fff;
}
// @ts-nocheck
import list from '../../../common/data/cook-list.json';
export default {
data: {
list: []
} ,
onInit() {
this.list=list.data
}
}