vm.$slots.default 该怎么赋值?
toast组件代码: <div class="ui-toast-content" v-if="$slots.default">
<slot></slot>
</div>
调用方代码:
if (!vm) {
const ToastConstructor = Vue.extend(ToastOptions)
vm = Toast._instance = new ToastConstructor({
propsData: {
content,
icon,
iconSvg,
duration,
position,
hasMask,
},
}).$mount()
}
如何 给 vm.$slots.default 赋值,可以让toast组件 的slot 渲染 自定义的html 字符串?
回答:
const node = Toast._instance.$createElement("div", { domProps: {
style:"text-align: center;",
innerHTML: `<img src=${require("@/assets/images/common/loading.jpg")}> <br>交易处理中...`
}
});
Toast._instance.$slots.default =[node];
以上是 vm.$slots.default 该怎么赋值? 的全部内容, 来源链接: utcz.com/p/935678.html