vux组件绑定事件

 

我一开始是这样绑定事件的,可是没有效果:spa

        <box gap="15px 45px">
          <x-button plain type="primary" style="border-radius:99px;border:none;background-color:#099eeb;color:#fff;" @click="fn">登陆</x-button>
        </box>

因而,经过仔细查看vux文档:code

这里很明白的说明:须要用@click.native来绑定:blog

        <box gap="15px 45px">
          <x-button plain type="primary" style="border-radius:99px;border:none;background-color:#099eeb;color:#fff;" @click.native="fn">登陆</x-button>
        </box>

这样就有效果了。事件

 

拓展,还有一种写法@click.native.prevent:文档

        <box gap="15px 45px">
          <x-button plain type="primary" style="border-radius:99px;border:none;background-color:#099eeb;color:#fff;" @click.native.prevent="fn">登陆</x-button>
        </box>

解释:event

 .prevent至关于加了一句event.preventDefault() ;
相关文章
相关标签/搜索