简体   繁体   English

Bootstrap-Vue-使子组件在b模式组件内工作

[英]Bootstrap-Vue - making a subcomponent work inside a b-modal component

So for some reason when I add a subcomponent to the <b-modal> component it doesn't display the modal properly. 因此由于某种原因,当我向<b-modal>组件添加子组件时,它无法正确显示模式。 It looks like the :is="currentModal" isn't being read properly. 看来:is =“ currentModal”无法正确读取。

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

Basically currentModal is the current component to display. 基本上,currentModal是要显示的当前组件。 if I change it so that currentModal is a string, like such, it still doesn't work properly either: 如果我更改它以使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>

If I remove the b-modal tags altogether the Login and Register components work like they're supposed to, so the problem seems to be that the Register and Login components aren't reading currentModal properly from within b-modal, for some reason. 如果我完全删除了b-modal标记,则Login和Register组件的工作应该像预期的那样,因此问题似乎是出于某种原因,Register和Login组件无法从b-modal内部正确读取currentModal。 Any help would be appreciated! 任何帮助,将不胜感激!

You need to use <b-container> as a direct child element of <b-modal> . 您需要将<b-container>用作<b-modal>的直接子元素。

In this case, it'll be something like below: 在这种情况下,将如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM