VUE3.0-VUE3.0生命周期和VUE2.X对比
VUE3.0中的生命周期都会比VUE2.X中早一点执行
beforeCreate -> 使用 setup()
created -> 使用 setup()
beforeMount -> onBeforeMount
mounted -> onMounted
beforeUpdate -> onBeforeUpdate
updated -> onUpdated
beforeDestroy -> onBeforeUnmount
destroyed -> onUnmounted
errorCaptured -> onErrorCaptured
<template>
<div class="home">
<p>{
{
msg}}</p>
<button @click="changeMsg">修改msg</button>
</div>
</template>
<script lang="ts">
import {
defineComponent,
ref,
onBeforeMount,
onMounted,
onBeforeUpdate,
onUpdated,
onBeforeUnmount,
onUnmounted
} from "vue";
export default