【问题标题】:Bootstrap-Vue - making a subcomponent work inside a b-modal componentBootstrap-Vue - 使子组件在 b-modal 组件中工作
【发布时间】:2018-11-29 20:50:45
【问题描述】:

因此,由于某种原因,当我将子组件添加到 <b-modal> 组件时,它无法正确显示模式。看起来 :is="currentModal" 没有被正确读取。

  <b-modal size="lg" v-model="currentModal" @ok="currentModal = null">
    <component :is="currentModal" :email="email"></component>
  </b-modal>

基本上 currentModal 是要显示的当前组件。如果我将其更改为 currentModal 是一个字符串,就像这样,它仍然无法正常工作:

  <b-modal size="lg" v-model="currentModal" @ok="currentModal = null">
    <Register v-if="currentModal=='register'":email="email"></Register>
    <Login v-if="currentModal=='login'" :email="email"><Login>
  </b-modal>

如果我完全删除 b-modal 标记,则 Login 和 Register 组件按预期工作,所以问题似乎是 Register 和 Login 组件没有从 b-modal 中正确读取 currentModal,因为一些理由。任何帮助将不胜感激!

【问题讨论】:

  • 您找到解决方案了吗?面临同样的问题,建议的答案不起作用。

标签: javascript vue.js bootstrap-vue


【解决方案1】:

您需要使用&lt;b-container&gt; 作为&lt;b-modal&gt; 的直接子元素。

在这种情况下,它将如下所示:

<b-modal size="lg" v-model="currentModal" @ok="currentModal = null">
    <b-container>
        <component :is="currentModal" :email="email"></component>
    </b-container>
</b-modal>

【讨论】:

猜你喜欢
  • 2019-12-15
  • 1970-01-01
  • 2020-01-21
  • 2020-09-08
  • 2017-04-03
  • 1970-01-01
  • 2018-10-04
  • 2016-10-19
  • 2020-03-07
相关资源
最近更新 更多