@marshal93/vue-directives
v0.1.1
Published
vue-directives with types
Downloads
34
Readme
@marshal93/vue-directives
===
INSTALL
npm i @marshal93/vue-directives -S
Usage
import Vue from 'vue';
import Directives from '@marshal93/vue-directives';
/**
* 挂载到全局组件
* @param {Object} options - 设置默认值
* @param {number} [options.x=50] - x position
* @param {number} [options.y=100] - y position
* @param {number} [options.langTapTimer=1000] - 长按按钮触发时间
*/
Vue.use(Directives, {
x: 200,
y: 300,
langTapTimer: 500
})
// Api
<button v-tap="handle">点击</button>
<button v-swipe="handle">滑动</button>
<button v-swipeLeft="handle">左滑</button>
<button v-swipeRight="handle">右滑</button>
<button v-swipeUp="handle">上滑</button>
<button v-swipeDown="handle">下滑</button>
<button v-longTap="handle">长按</button>
/**
* stop 阻止冒泡
prevent 阻止默认事件
self 只当在 event.target 是当前元素自身时触发处理函数
once 执行一次后解绑
*/
<button v-tap.stop.prevent.self.once="handle">修饰符</button>