index.js
757 Bytes
const tableScroll = (columns, y) => {
const status = typeof y == "string" || typeof y == 'number'
const status_two = typeof columns == "string" || typeof columns == 'number'
let _y = status ? y : document.body.clientHeight - y.getBoundingClientRect().top - 150;
let opt = {
x: status_two ? columns : columns.reduce((c, n) => {
let cn = typeof c == "number" ? c : parseInt(c['width'] || 300);
let nn = parseInt(n['width'] || 300);
return cn + nn;
}),
y: Math.max(_y, 300)
}
return opt
}
// 封装接口返回数据
const handlePromise = (promise) => {
return promise.then(res => {
return Promise.resolve(res)
}).catch(e => {
return Promise.resolve(res)
})
}
export {
tableScroll,
handlePromise
}