page.uvue 916 字节
Newer Older
H
hdx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<template>
	<view class="page">
		<text>page lifecycle</text>
	</view>
</template>

<script lang="ts">
	import { state, setLifeCycleNum } from '@/store/index.uts'
	export default {
		onLoad() {
			setLifeCycleNum(state.lifeCycleNum + 100)
			console.log('Page onLoad')
		},
		onShow() {
			setLifeCycleNum(state.lifeCycleNum + 10)
			console.log('Page onShow')
		},
		onReady() {
			setLifeCycleNum(state.lifeCycleNum + 10)
DCloud-WZF's avatar
DCloud-WZF 已提交
20
			console.log('Page onReady')
H
hdx 已提交
21 22 23 24 25 26 27 28 29 30 31
		},
		onHide() {
			setLifeCycleNum(state.lifeCycleNum - 10)
			console.log('Page onHide')
		},
		onUnload() {
			setLifeCycleNum(state.lifeCycleNum - 100)
			console.log('Page onUnload')
		},
		onBackPress(options: Map<string, string>) : boolean | null {
			setLifeCycleNum(state.lifeCycleNum - 10)
DCloud-WZF's avatar
DCloud-WZF 已提交
32
			console.log('Page onBackPress',options)
H
hdx 已提交
33 34 35 36 37 38 39 40
			return null
		},
		methods: {
			getLifeCycleNum() : number {
				return state.lifeCycleNum
			}
		},
	}
DCloud-WZF's avatar
DCloud-WZF 已提交
41
</script>