vue抽象组件拦截事件

新手上路,请多包涵
<is-abstract>
      <is-show />
    </is-abstract>
export default {
  abstract: true,
  name: "is-abstract",
  render() {
    const slot = this.$slots.default;
    const vNode = slot[0];
    const componentOptions = vNode && vNode.componentOptions;
    const componentInstance = vNode && vNode.componentInstance;
    return vNode;
  },
};
<template>
  <div class="">
    <el-button @click="clickAction">click</el-button>
  </div>
</template>

<script>
export default {
  components: {},
  name: 'is-show ',
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {
    clickAction() {
      this.$emit("upload", "upload");
    },
  },
  created() {},
  mounted() {},
};
</script>

如何在抽象函数中拦截@upload事件

阅读 1.8k
1 个回答

你是指这样?

// is-abstract
mounted() {
        this.$slots.default[0].componentInstance.$on('upload', arg => console.log('拦截',arg))
  },
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题