page-lifecycle.uvue 958 字节
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
<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)
			console.log('Page onReady')
		},
		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)
			console.log('Page onBackPress',options)
			return null
		},
		methods: {
			getLifeCycleNum() : number {
				return state.lifeCycleNum
			}
		},
	}
</script>