如何为element ui的el-tab-pane组件增加自定义事件?

需求:
一个抽像对象:person,多个具体对象: xxx_person. 内容页(/view)中有一个tab, 根据不同的xxx_person来显示不同的tab. 例: a_person的内容页(/view)有三个tab, b_person的内容页(/view)有四个tab.

现在:

    <el-tabs v-model="baseTabActiveName" type="card" @tab-click="handleClick" v-if="isReadyBuild">
      <el-tab-pane v-for="(item,index) in corpInfoStepList" 
          :id="item.names" 
          :key="index" 
          :ref="item.names" 
          :label="item.title" 
          :name="item.names" 
          @dictArgBubble="listenDictArgEnroll"
          @attaSctionBubble="listenAttaSctionEnroll" 
          @hook:mounted="childItpMounted(item.key)">
        <!-- keeplive-->
          <tab-pane :is="item.key" :ref="item.key" :type="item.key" :apply-obj.sync="localApplyInstance" :apply-id.sync="localApplyId" />
        <!-- keeplive-->
      </el-tab-pane>
    </el-tabs>

问题:
希望通过:dictArgBubble来收集子标签组件的字典, attaSctionBubble来收集子标签组件的附件id, 以此来减少请求的次数。但发现: listenDictArgEnroll未被执行

阅读 2.3k
1 个回答

答案:

    <el-tabs v-model="baseTabActiveName" type="card" @tab-click="handleClick" v-if="isReadyBuild">
      <el-tab-pane v-for="(item,index) in corpInfoStepList" 
          :id="item.names" 
          :key="index" 
          :ref="item.names" 
          :label="item.title" 
          :name="item.names">
        <!-- keeplive-->
          <component :is="item.key" 
            :ref="item.key" 
            :type="item.key"  
            :apply-obj.sync="localApplyInstance" 
            :apply-id.sync="localApplyId" 
            @create="showCreatedTimes"
            @dictArgBubble="listenDictArgEnroll"
            @attaSctionBubble="listenAttaSctionEnroll"
            @hook:mounted="childItpMounted(item.key)" />
        <!-- keeplive-->
      </el-tab-pane>
    </el-tabs>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题