Vue.js 对通过配置对象传递的动态组件使用Vue:is-prop

Vue.js 对通过配置对象传递的动态组件使用Vue:is-prop,vue.js,Vue.js,我有一个确认弹出窗口Vue组件,其配置对象如下: { title: null, message: null, onConfirm: null, onDismiss: null, modal_class: null, icon: null, confirmBtnText: null, confirmBtnColor: null, component: null } 在模板中,我希望在此处呈现“动态”组件: <component class="compon

我有一个确认弹出窗口Vue组件,其配置对象如下:

{
  title: null,
  message: null,
  onConfirm: null,
  onDismiss: null,
  modal_class: null,
  icon: null,
  confirmBtnText: null,
  confirmBtnColor: null,
  component: null
}
在模板中,我希望在此处呈现“动态”组件:

<component class="component-container" :is="component"></component>
但我得到了一个错误:

Failed to mount component: template or render function not defined.
编辑: 我现在尝试使用组件的实际
$options
对象,将其扩展如下:

<component class="component-container" :is="component.$options"></component>

因此,正在取得进展,但由于某些原因,
propsData
没有填充到渲染函数中。

这看起来相当相关:


通过此处的语法:

我想你是在寻找
v-bind
而不是
is
。如果希望将所有内容作为一个对象保留,可以在
v-bind
中包含
is

const CarrierSaferInfo={
道具:{
dom_类:String,
承运人:{
要求:正确,
类型:字符串
}
},
模板:“{{carrier}}”
}
新Vue({
el:“#应用程序”,
数据(){
返回{
组件:空
}
},
方法:{
onClick(){
此.component={
is:CarrierSaferInfo,
航母:“你好”,
dom_类:“文本白色”
}
}
}
})

打开

我认为不能将'is'属性绑定到div元素。。。你有没有试过:@SirDad我刚试过,它也会出现同样的错误我不熟悉你初始化它的方式,但是
:is
使用
字符串
:SatyamPathak我之所以这样初始化组件,是因为每次初始化组件时都需要更改道具。从文档中,
:is
道具将采用名称(您的建议)或组件选项对象(我的示例所需)是!这工作得很好…不知道为什么在文档的动态组件部分没有提到它。我只是做了
忽略最后一条评论-它不起作用。我需要这个:
@MikeHarrison这表明你还是找错人了。您不需要靠近
$options
propsData
。我在我的第一个示例下面添加了更多的解释,试图阐明它是如何应用于您的场景的。谢谢@skillle-我已将其更改为
,并为
openconfirmdalog()
<component class="component-container" :is="component.$options"></component>
Missing required prop: carrier
<component :is=”currentComponent” v-bind=”currentProperties”></component>