Merge branch 'kp-add-vue-create-component-helper' into 'master'
Add `createComponentWithMixin` to create anonymous components with mixins See merge request gitlab-org/gitlab-ce!18899
This commit is contained in:
commit
1a103161f7
1 changed files with 19 additions and 3 deletions
|
@ -1,14 +1,30 @@
|
|||
import Vue from 'vue';
|
||||
|
||||
const mountComponent = (Component, props = {}, el = null) => new Component({
|
||||
propsData: props,
|
||||
}).$mount(el);
|
||||
|
||||
export const createComponentWithStore = (Component, store, propsData = {}) => new Component({
|
||||
store,
|
||||
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 }) =>
|
||||
new Component({
|
||||
store,
|
||||
propsData: props || { },
|
||||
}).$mount(el);
|
||||
|
||||
export default (Component, props = {}, el = null) => new Component({
|
||||
propsData: props,
|
||||
}).$mount(el);
|
||||
export default mountComponent;
|
||||
|
|
Loading…
Reference in a new issue