vxe-table
Version:
一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟滚动、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、虚拟列表、模态窗口、自定义模板、渲染器、贼灵活的配置项、扩展接口等...
39 lines (34 loc) • 1.02 kB
JavaScript
import XEUtils from 'xe-utils/ctor'
function toType (type) {
return XEUtils.toString(type).replace('_', '').toLowerCase()
}
const eventTypes = 'created,mounted,activated,beforeDestroy,destroyed,event.clearActived,event.clearFilter,event.showMenu,event.keydown,event.export,event.import'.split(',').map(toType)
const storeMap = {}
const interceptor = {
mixin (map) {
XEUtils.each(map, (evntFn, type) => interceptor.add(type, evntFn))
return interceptor
},
get (type) {
return storeMap[toType(type)] || []
},
add (type, evntFn) {
type = toType(type)
if (evntFn && eventTypes.indexOf(type) > -1) {
let eList = storeMap[type]
if (!eList) {
eList = storeMap[type] = []
}
eList.push(evntFn)
}
return interceptor
},
delete (type, evntFn) {
const eList = storeMap[toType(type)]
if (eList) {
XEUtils.remove(eList, fn => fn === evntFn)
}
return interceptor
}
}
export default interceptor