add plugins extend
This commit is contained in:
parent
9964f4e75c
commit
06227afaf5
|
@ -0,0 +1,5 @@
|
||||||
|
import methodsExtend from './methodsExtend'
|
||||||
|
|
||||||
|
export default function (Vue) {
|
||||||
|
methodsExtend(Vue)
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
const { parse, stringify } = JSON
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description deep clone obecjt
|
||||||
|
* @return {object} clone
|
||||||
|
*/
|
||||||
|
export function deepClone (object) {
|
||||||
|
return parse(stringify(object))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteArrayAllItems (arrays) {
|
||||||
|
arrays.forEach(element => element.splice(0, element.length))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function debounce (delay, callback) {
|
||||||
|
let lastTime
|
||||||
|
|
||||||
|
return function () {
|
||||||
|
clearTimeout(lastTime)
|
||||||
|
|
||||||
|
const [that, args] = [this, arguments]
|
||||||
|
|
||||||
|
lastTime = setTimeout(() => {
|
||||||
|
callback.apply(that, args)
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function (Vue) {
|
||||||
|
Vue.prototype.deepClone = deepClone
|
||||||
|
Vue.prototype.deleteArrayAllItems = deleteArrayAllItems
|
||||||
|
Vue.prototype.debounce = debounce
|
||||||
|
}
|
Loading…
Reference in New Issue