UNPKG

vue-tabulation

Version:

a vue based table component

50 lines (48 loc) 988 B
// 排序根据固定列重排 export function sortFixed(arr) { return arr.sort((a, b) => { function getWeight(fixed) { if (!fixed) { return 0 } else if (fixed === 'right') { return -1 } else { return 1 } } return getWeight(b.fixed) - getWeight(a.fixed) }) } /** * 深拷贝 * @param {*} obj */ export function deepClone(obj) { return JSON.parse(JSON.stringify(obj)) } /** * 利用 requestAnimationFrame 进行 throttle * @param {function} fn */ export function rAF (fn) { let ticking = false let update = function (...arg) { ticking = false fn.apply(this, arg) } return function (...arg) { let self = this; if(!ticking) { requestAnimationFrame(function() { update.apply(self, arg) }); } ticking = true; } } // 调试代码 export function debug (...arg) { if (process.env.NODE_ENV === 'development') { console.log(...arg) } }