Why does this component emit event in Vue3 ?? #6585
              
                
                  
                  
                    Answered
                  
                  by
                    liulinboyi
                  
              
          
                  
                    
                      junholee14
                    
                  
                
                  asked this question in
                Help/Questions
              
            -
| 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.
      
      
          Answered by
          
            liulinboyi
          
      
      
        Sep 4, 2022 
      
    
    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.
                  
                    2 replies
                  
                
            
      Answer selected by
        junholee14
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
The reason is v-on Listener Inheritance.
https://vuejs.org/guide/components/attrs.html#v-on-listener-inheritance
You can add
inheritAttrs: falseto disabling Attribute Inheritance.https://vuejs.org/guide/components/attrs.html#disabling-attribute-inheritance
Modify the Codes:
MyGroup.vue
or
MyGroup.vue