vue3 生命周期的调用
2024-01-11 本文已影响0人
天上飞的狒狒
<script>
import { onBeforeMount, onBeforeUpdate, onMounted, onUpdated } from "vue";
export default {
name: "About",
setup() {
onBeforeMount(() => {
console.log("在组件被挂载之前被调用");
});
onMounted(() => {
console.log("在组件挂载完成后执行");
});
//
onBeforeUpdate(() => {
console.log("更新前");
});
onUpdated(() => {
console.log("绑定的数据更新了");
});
onErrorCaptured(() => {
console.log("在捕获了后代组件传递的错误时调用");
});
onBeforeUnmount(() => {
console.log("在组件实例被卸载之前调用");
});
onUnmounted(() => {
console.log("在组件实例被卸载之后调用");
});
},
};
</script>