pure-scroll
Version:
一个简洁且好用的滚动库, 基于better-scroll封装
23 lines (21 loc) • 333 B
JavaScript
/**
* timeout mixin
*/
export const TimeoutMixin = {
data () {
return {
timer: null
};
},
methods: {
timeout (fn, time) {
clearTimeout(this.timer);
setTimeout(() => {
typeof fn === 'function' && fn();
}, time);
}
},
beforeDestroy () {
clearTimeout(this.timer);
}
};