<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://unpkg.com/vue@next"></script>
</head>
<body>
<div id="root"></div>
</body>
<script>
const app = Vue.createApp({
data() {
return {
hello: "hello world",
};
},
beforeCreate() {
console.log("beforeCreate: 在实例生成之前会自动执行的函数");
},
created() {
console.log("created: 在实例生成之后会自动执行的函数");
},
beforeMount() {
console.log(
"beforeMount: 在组件内容被渲染到页面之前自动执行的函数....."
);
},
mounted() {
console.log("mounted: 在组件内容被渲染到页面之后自动执行的函数");
},
beforeupdate() {
consloe.log(
" beforeUpdate: 当数据发生变化时会立即自动执行的函数。。。。"
);
},
updated() {
console.log(
"updated: 当数据发生变化,页面重新渲染后,会自动执行的函数"
);
},
beforeUnmount() {
console.log(" beforeUnmount: 当 Vue 应用失效时,自动执行的函数");
},
unmounted() {
console.log(
"unmounted: 当 Vue 应用失效时,且 dom 完全销毁之后,自动执行的函数"
);
},
template: `
<h1>{{hello}}</h1>
`,
});
</script>
</html>