why does the function excute twice in child component? #7527
Answered
by
LinusBorg
zhoufanglu
asked this question in
Help/Questions
-
Vue version3.2.25 Link to minimal reproductionhttps://codesandbox.io/s/affectionate-snow-p9eu4z?file=/src/App.vue Steps to reproduce
<template>
<HelloWorld :msg="msg" />
</template>
<script>
import HelloWorldVue from "./components/HelloWorld.vue";
import { ref } from "vue";
export default {
name: "App",
components: {
HelloWorld: HelloWorldVue,
},
setup() {
const msg = ref("");
setTimeout(() => {
msg.value = "aaaaa";
}, 1000);
return {
msg,
};
},
};
</script>
export default {
name: "HelloWorld",
props: {
msg: String,
},
setup() {
const fn = () => {
console.log("xxxxx");// excute twice
};
return {
fn,
};
},
}; What is expected?i think this fn will excute once What is actually happening?fn excute twice System InfoNo response Any additional comments?No response |
Beta Was this translation helpful? Give feedback.
Answered by
LinusBorg
Jan 13, 2023
Replies: 1 comment 4 replies
-
Because:
|
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
LinusBorg
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because:
msg
prop changes.