Why does this component emit event in Vue3 ?? #6585
-
Code : Expectation :
What happens :
I don't understand why this is happening because i don't specify to emit "dragend" event in MyGroup.vue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The reason is v-on Listener Inheritance. https://vuejs.org/guide/components/attrs.html#v-on-listener-inheritance You can add https://vuejs.org/guide/components/attrs.html#disabling-attribute-inheritance Modify the Codes: MyGroup.vue <template>
<v-group :x="100" :y="100">
<v-rect :x="0" :y="0" :width="100" :height="100" fillStyle="red" />
<v-rect :x="50" :y="50" :width="100" :height="100" fillStyle="blue" />
</v-group>
</template>
<script>
import VGroup from "./VGroup";
import VRect from "./VRect";
export default {
inheritAttrs: false,
components: { VRect, VGroup },
};
</script> or MyGroup.vue <template>
<div>
<v-group :x="100" :y="100">
<v-rect :x="0" :y="0" :width="100" :height="100" fillStyle="red" />
<v-rect :x="50" :y="50" :width="100" :height="100" fillStyle="blue" />
</v-group>
</div>
</template>
<script>
import VGroup from "./VGroup";
import VRect from "./VRect";
export default {
components: { VRect, VGroup },
};
</script> |
Beta Was this translation helpful? Give feedback.
The reason is v-on Listener Inheritance.
https://vuejs.org/guide/components/attrs.html#v-on-listener-inheritance
You can add
inheritAttrs: false
to disabling Attribute Inheritance.https://vuejs.org/guide/components/attrs.html#disabling-attribute-inheritance
Modify the Codes:
MyGroup.vue
or
MyGroup.vue