Open
Description
Vue version
fbc0c42(default version of playground on 21Aug24)
Link to minimal reproduction
Steps to reproduce
Can see the right side of the page.
What is expected?
I expected to see from created() function
, as the lifecycle diagram shows the created will be executed after setup
and Options API
:
What is actually happening?
I saw from data() function
, seems the created hook is ignored.
System Info
No response
Any additional comments?
if i change the place of setup
and data
, the issue disappears. the following data works as expected.
<template>
<h1>{{ msg }} </h1>
</template>
<script>
import { ref } from 'vue';
export default {
data() {
return {
msg: "from data() function"
};
},
setup() {
const msg = ref("helloworld");
// Callback logic that runs at the 'created' stage
const callback = () => {
console.log("Callback executed");
msg.value = "from function call inside setup()";
};
// Directly call the callback
callback();
return {
msg
};
},
created(){
this.msg = "from created() function"
}
}
</script>