Vue v-on:click does not work on component

前端 未结 7 1458
日久生厌
日久生厌 2020-11-27 11:16

I\'m trying to use the on click directive inside a component but it does not seem to work. When I click the component nothings happens when I should get a \'test clicked\' i

7条回答
  •  天命终不由人
    2020-11-27 11:56

    I think the $emit function works better for what I think you're asking for. It keeps your component separated from the Vue instance so that it is reusable in many contexts.

    // Child component
    
    

    Use it in HTML

    // Parent component
    
    

提交回复
热议问题