模态仅在第二次单击后显示 [英] Modal only showing after the second click
问题描述
我正在 vue2 中以 1 个组件 = 1 个文件样式进行开发.
I'm developing in 1 component = 1 file style in vue2.
我有一个通过 Bootstrap-Vue 表格组件构建的表格,我正在使用提供程序向它传递一个项目.
I have a Table constructed via a Bootstrap-Vue Table Component, I'm using the provider to pass it an items.
其中一列包含每一行的修改按钮.
one of the columns contains modify buttons for each row.
这些按钮触发引导模式.
these buttons trigger a bootstrap-modal.
我正在使用 V-if 来初始化表及其属性.
I'm using a V-if to initialize the table and its properties.
<b-modal v-if='toShow' id="modalallergy" @hide="resetModal">
<h4 class="my-1 py-1" slot="modal-header">Allergie {{ modalDetails._id }}</h4>
<b-container class="bv-example-row">
<b-row>
<b-col>
identifiant : {{modalDetails.data.content}}
</b-col>
<b-col>
Catégorie : {{modalDetails.data.content}}
</b-col>
</b-row>
</b-container>
</b-modal>
<b-modal id="modalallergy-edit" @hide="resetModal">
<h4 class="my-1 py-1" slot="modal-header">Edition de l'allergie {{ modalDetails._id }}</h4>
<pre>{{ modalDetails.data}}</pre>
</b-modal>
这是我的模态,就在我的按钮上方:
this is my modal and just above I have my button :
<button class="btn btn-xs btn-success" @click.stop="details(row.item,row.index,$event.target)">
<span class="glyphicon glyphicon-search"></span>
</button>
和下面的 和
methods
部分我有我的电话:
and below in the <script>
and methods
section I have my call :
details (item, index, button) {
this.modalDetails.data = item
this.modalDetails.index = index
this.modalDetails._id = item.content._id
this.$root.$emit('bv::show::modal', 'modalallergy', button)
}
问题是只有第二次点击按钮才会触发模态打开.(表的属性还没有被水合——至少从按钮和模态的角度来看没有.)
the issue is that only the second click on the button will trigger the modal opening. (The properties of the table have not been hydrated yet - at least not from the point of view of the button and modal.)
我也尝试使用布尔值并手动传递参数,但在这种情况下它根本没有打开.
I also tried using a Boolean and passing the params manually but in that case it doesn't open at all.
推荐答案
你应该已经解决了这个问题,但对于未来的尝试,这是我的意见.我有一个类似的问题.在我的情况下,问题是用于初始化模态内组件的 v-if.我相信如果您将 v-if 更改为 h4 和 b-container 标签会起作用.
You should have solved the problem, but for future attempts it's my opinion. I had a similar problem. In my case the problem was the v-if used to initialize components inside the modal. I belive if you change the v-if to the h4 and b-container tags will work.
这篇关于模态仅在第二次单击后显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!