Skip to content

Instantly share code, notes, and snippets.

@njleonzhang
Last active November 30, 2017 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njleonzhang/248ac62deaff2ce9ceaf8119cba115a6 to your computer and use it in GitHub Desktop.
Save njleonzhang/248ac62deaff2ce9ceaf8119cba115a6 to your computer and use it in GitHub Desktop.
try vue hoc
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