uni-app lifecycle

 

Life cycle is divided into: the page lifecycle and application lifecycle

 

Life cycle may refer to: UNI-official App API

 

Note platform support, platform support only one will be displayed, 5 + App of App ultra HTML5 + program.

 

Such as sharing: Only small program support then we will adopt a cross-end solutions: https://uniapp.dcloud.io/platform

 

1. Application Lifecycle

 

2. The page life cycle

<template>
    <view class="content">
        <image class="logo" src="../../static/image/myHover.png" @click="tap"></image>
        <view>
            <text class="title">{{title}}</text>
        </view>
    </view>
</template>

<script>
    
    // 跨终端解决方案:https://uniapp.dcloud.io/platform
    // 生命周期:https://uniapp.dcloud.io/frame?id=%E9%A1%B5%E9%9D%A2%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F
    
    export default {
        data() {
            return {
                title: 'Hello'
            }
        },
        onLoad() {
            console.log('页面加载')
        },
        onShow() {
            console.log('页面显示')
        },
        onReady(){
            console.log('页面初次显示')
        },
        onHide() {
            console.log('页面隐藏')
        },
        onUnload() {
            console.log('页面卸载')
        },
        onBackPress(){
            console.log('页面返回...')
        },
        onShareAppMessage() {
            console.log('分享!')
        },
        onReachBottom() {
            console.log('下拉加载...')
        },
        onPageScroll(){
            console.log('页面滚动...')
        },
        onPullDownRefresh() {
            console.log('上拉刷新...')
            uni.stopPullDownRefresh();
        },
        
        // #ifdef APP-PLUS
        onNavigationBarButtonTap(){
            
        },
        // #endif
        
        methods: {
            tap(){
                console.log('tap点击!');
            }
        }
    }
</script>

<style lang="scss">
    .content {
        text-align: center;
        height: 400upx;
    }

    .logo {
        height: 200upx;
        width: 200upx;
        margin-top: 200upx;
    }

    .title {
        font-size: 36upx;
        color: #8f8f94;
    }
</style>

 

页面栈以何种方式进入或退出以及tabbar的路由切换触发页面生命周期的行为.

 

Guess you like

Origin www.cnblogs.com/fei-H/p/11304645.html