How to click on whole vuejs component

后端 未结 1 409
旧巷少年郎
旧巷少年郎 2021-01-21 01:12

I have component

and i want run method after click


i have th

相关标签:
1条回答
  • 2021-01-21 01:34
    1. Register your component, and declare the handler method inside:

      Vue.component('my-component', {
          // ...
          methods: {
              showOtherDiv : function(){
                  alert('Some message');
              }
          }
      });
      
    2. Add the .native modifier to the event name:

      <my-component @click.native="showOtherDiv"></my-component>
      

      From the docs:

      Binding Native Events to Components

      […] when you want to listen for a native event on the root element of a component […] you can use the .native modifier for v-on.

    0 讨论(0)
提交回复
热议问题