我有以下带有插槽的组件:
<template>
<div>
<h2>{{ someProp }}</h2>
<slot></slot>
</div>
</template>
由于某些原因,我必须手动实例化这个组件.我就是这样做的:
const Constr = Vue.extend(MyComponent);
const instance = new Constr({
propsData: { someProp: 'My Heading' }
}).$mount(body);
The problem is: I am not able to create slot contents programmatically.到目前为止,我可以创建简单的基于字符串的插槽:
const Constr = Vue.extend(MyComponent);
const instance = new Constr({
propsData: { someProp: 'My Heading' }
});
// Creating simple slot
instance.$slots.default = ['Hello'];
instance.$mount(body);
The question is - how can I create 100 programmatically and pass it to the instance I am creating using 101?
Note: I am not using a full build of Vue.js (runtime only). So I don't have a Vue.js compiler available to compile the template on the fly.