Commit 7877edec authored by Kushal Pandya's avatar Kushal Pandya

Add `createComponentWithMixin` to create anonymous components with mixin

parent 03401338
import Vue from 'vue';
const mountComponent = (Component, props = {}, el = null) => new Component({
propsData: props,
}).$mount(el);
export const createComponentWithStore = (Component, store, propsData = {}) => new Component({ export const createComponentWithStore = (Component, store, propsData = {}) => new Component({
store, store,
propsData, propsData,
}); });
export const createComponentWithMixin = (mixins = [], state = {}, props = {}, template = '<div></div>') => {
const Component = Vue.extend({
template,
mixins,
data() {
return props;
},
});
return mountComponent(Component, props);
};
export const mountComponentWithStore = (Component, { el, props, store }) => export const mountComponentWithStore = (Component, { el, props, store }) =>
new Component({ new Component({
store, store,
propsData: props || { }, propsData: props || { },
}).$mount(el); }).$mount(el);
export default (Component, props = {}, el = null) => new Component({ export default mountComponent;
propsData: props,
}).$mount(el);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment