Vue生命周期
Vue中常见生命周期节点
- created:组件实例被创建之后调用。
- mounted:组件挂载到DOM后调用。
- updated:组件数据更新后调用。
- destroyed:组件销毁后调用。
例子
<template>
<div class="hello">
<el-row style="margin-top: 10px">
<el-col :span="12">
<span>{{this.outTag()}}</span>
</el-col>
</el-row>
</div>
</template>
<script>
export default {
name: "HelloWorld1",
data() {
return {
};
},
watch: {},
mounted() {
console.log("=====> mounted ");
},
beforeCreate() {
console.log("=====> beforeCreate ");
},
created() {
console.log("=====> created ");
},
methods: {
outTag() {
console.log("=====> outTag method");
}
},
};
</script>
<style scoped></style>
参考
https://cn.vuejs.org/api/composition-api-lifecycle.html