我有一个动态组件,它使用文档中记录的动态组件语法在运行时解析并绑定;
<div class="field">
<component v-if="component" :is="component" @valueUpdated="onUpdate($event)"></component>
</div>
使用在安装时分配的prop进行决定。
由于某种原因,当动态渲染的子组件发出事件this.$emit('eventName', /*someData*/)
时,父组件似乎无法听到它。在动态渲染的组件中使用的方法是否适用于标准组件?Prop似乎起作用了,所以也许我做错了什么?
this.$emit('value-updated', { foo: 'bar' })
- GuyCv-if="currentComponent"
,在上面的示例中更有意义,即在尝试实例化之前测试是否存在currentComponent
字符串。 - GuyC