I have the following component with a slot:
{{ someProp }}
(This doesn't really answer How to create Vue.js slot programatically?
. But it does solve your problem.)
This trick is less hackish compared to using $createElement()
.
Basically, create a new component that register MyComponent
as a local component.
const Constr = Vue.extend({
template: `
slot here !!!
`,
components: {
MyComponent: MyComponent
}
});
const instance = new Constr().$mount('#app');
Demo: https://jsfiddle.net/jacobgoh101/shrn26p1/