【发布时间】:2020-03-29 01:40:24
【问题描述】:
我有一个按钮,应该从一个孩子打开一个模式,添加一个新客户。
如果我的代码只是在父级中,它可以工作,但我尝试在子级中实现它。
家长
<b-button @click="openModal">Add new customer</b-button>
<add-new-customer ref="modal" v-if="addCustomer"></add-new-customer>
openModal() {
this.$refs.modal.openModalCh()
},
儿童
<b-modal
id="modal-prevent-closing"
ref="modal"
title="Add new customer"
@ok="addCustomer"
>
...code..
</b-modal>
<add-new-customer ref="modal" v-if="addCustomer" @added="onAddCustomer"></add-new-customer>
addCustomer() {
..code for post a new customer..
}
openModal() {
this.$refs.modal.openModalCh()
},
【问题讨论】:
标签: vue.js vuejs2 bootstrap-vue