You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
471 B
14 lines
471 B
3 months ago
|
class Mixin {
|
||
|
constructor ({component, props, events, extraProps, exceptProps}) {
|
||
|
this.render = function (h) {
|
||
|
return h(component, {
|
||
|
props: props.reduce((obj, key) => Object.assign(obj, {[key]: this[key]}), {}),
|
||
|
on: events.reduce((obj, key) => Object.assign(obj, {[key]: this.transmitEvent}), {})
|
||
|
})
|
||
|
}
|
||
|
this.props = [...extraProps, ...props.filter(prop => exceptProps.indexOf(prop))]
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default prop => new Mixin(prop)
|