Skip to content
/ vuepfc Public

Vue directive to prevent fast click.very useful in projects with frequent requests to the backend interface.

License

Notifications You must be signed in to change notification settings

wuyax/vuepfc

Repository files navigation

vuepfc

vuepfc是一个Vue插件,它提供一个非常有用的Vue指令,用于阻止用户快速的连续点击行为。用户第一次点击的时候会立即调用callback,在wait(default = 500ms)时间内的重复调用都会被取消。在后台管理系统中用于优化用户交互体验非常有用。

Test Downloads Version License Issuse

Usage

npm install vuepfc --save
// install plugin
import vuepfc from 'vuepfc'

Vue.use(vuepfc)

简单使用

// template
<button v-pfc="clickMe">vue pfc</button>

// script
methods: {
  clickMe() {
    console.log('click')
  }
}

自定义时间间隔

wait默认时间是500ms,你可以根据需要修改该参数。

// template
<button v-pfc="{wait: 300, callback: clickMe}">vue pfc</button>

// script
methods: {
  clickMe() {
    console.log('click')
  }
}

支持的指令修饰符

阻止冒泡:v-pfc.stop = callback

阻止默认行为:v-pfc.prevent = callback

Contribution

欢迎贡献你的代码。

License

MIT

About

Vue directive to prevent fast click.very useful in projects with frequent requests to the backend interface.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published