假设组件名称是“customComponent”
及其用法示例:
<custom-component class='parent'>
<div v-if='someTruthyCondition'>
<custom-component class='child'></custom-component>
</div>
</custom-component>
假设“someTruthyCondition”为真,生成 3 个组件并停止递归。
我想知道如何在vue js中子customComponent与父customComponent之间进行通信?
最佳答案
You can use functions as props in Vue.js. It’s not a common pattern because, unlike with React, Vue.js has custom events for child-to-parent communication. But for cases like this one it really comes in handy.
Unlike emitting events at each level, this is much simpler and performant since we only need to pass down the same reference to the function.
检查 this出。
关于javascript - vuejs 2.0 中的递归组件通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47012103/