Last active
November 30, 2017 13:49
-
-
Save njleonzhang/248ac62deaff2ce9ceaf8119cba115a6 to your computer and use it in GitHub Desktop.
try vue hoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {DataTables as oDataTables, DataTablesServer as oDataTablesServer} from 'vue-data-tables' | |
import Vue from 'vue' | |
let dataTablesHoc = Component => { | |
return { | |
components: { | |
[Component.name]: Component | |
}, | |
render() { | |
let attrs = { | |
attrs: Object.assign({ | |
tableProps: { | |
stripe: false, | |
border: false | |
} | |
}, this.$attrs) | |
} | |
return ( | |
<Component {...attrs} {...{on: this.$listeners}}> | |
<template slot='custom-tool-bar'> | |
{ this.$slots['custom-tool-bar'] } | |
</template> | |
{ this.$slots.default } | |
</Component> | |
) | |
} | |
} | |
} | |
Vue.component('DataTables', dataTablesHoc(oDataTables)) | |
Vue.component('DataTablesServer', dataTablesHoc(oDataTablesServer)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment