Why is it that modifying data in beforeCreated/created/beforeMount does not activate the watch function in Vue?
<template>
<div>
<titi :namer="parentName"></titi>
</div>
</template>
<script>
export default {
components: {
titi: {
template: "<h1>{{namer}}</h1>",
props: ["namer"],
watch: {
namer: {
immediate: false,
handler(val, oldVal) {
console.log("jackieyin", val);
}
}
},
mounted() {
console.log("jackieyin", "mounted");
}
}
},
data: function() {
return {
parentName: "jackieyin"
};
},
beforeCreate() {
console.log(222);
this.parentName = "sunwukong";
},
created() {
this.parentName = "kewu";
},
beforeMount() {
this.parentName = "tangseng";
},
mounted() {
// var that = this;
// this.parentName = "tyty";
// setTimeout(() => {
// that.parentName = "shaseng";
// }, 500);
}
};
</script>
Despite my attempts to modify the data during these lifecycle stages, the child element's props watch function remains inactive. Feel free to experiment with it here: https://codesandbox.io/s/vue-watch-inx4z