以编程方式绑定VueJS中动态组件的自定义事件

Vue.js

老丝米亚

2020-03-16

在我的vuejs应用程序中,我通过以下方式使用动态组件:

<mycomponent>
  <component ref="compRef" :is="myComponent" v-bind="myComponentProps"></component>
  <div class="my-buttons">        
    <my-button label="Reset" @click="reset()"/>
  </div>
</mycomponent >

myComponent是父组件上的道具,其中包含要注入的实际组件。 myComponentProps也是支撑注入实例实例的道具的道具。

我想知道如何将侦听器动态绑定到组件-我知道我无法通过多个事件将对象发送到v-on。

我正在考虑以编程方式添加它,但是还没有找到有关如何对Vue自定义事件进行处理的任何信息(addEventListener与自定义事件等效)

任何提示将不胜感激!

第1672篇《以编程方式绑定VueJS中动态组件的自定义事件》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android