【发布时间】:2019-09-21 12:33:35
【问题描述】:
在我的项目codesandbox:
模板:
<template>
<b-button variant="link" class="btn-remove" @click="removeItemFromOrder(index)">
Remove item
</b-button>
</template>
使用自定义内容生成模式的脚本:
<script>
export default {
name: "HelloWorld",
methods: {
removeItemFromOrder: async function (position) {
let self = this
const h = this.$createElement
const titleVNode = h('div', { domProps: { innerHTML: '<h2>Remove this item?</h2>' } })
const messageVNode = h('div', { class: ['modal-complete'] }, [
h('div', {
domProps: {
innerHTML: '<h2>Remove this item?</h2>'+
'<span class="popup-meta">'+
'Are you sure you want to remove this item?'+
'</span>'
}
})
])
this.$bvModal.msgBoxConfirm([messageVNode], {
title: [],
centered: true,
modalClass: 'success-popup',
hideHeader:true,
footerClass: 'd-flex justify-content-center align-items-center',
cancelVariant: 'outline-danger',
okVariant: 'danger',
okTitle: 'YES',
cancelTitle: 'NO',
ststic: false
})
.then(async function (result) {
if (result) {
self.currentOrder.items.splice(position, 1)
await self.sync()
}
})
.catch(err => {
// An error occurred
})
},
}
};
</script>
现在打开追加到body 后的引导模式。所以,这就是为什么我有一个问题:
如何将 bootstrap-vue 模态附加到 #app 或其他模板\标签?
P.S: 仅适用于this.$bvModal.msgBoxConfirm 和then ...以免创建不必要的方法...
由于具有不同逻辑的弹出窗口数量
【问题讨论】:
-
你到底想做什么?
-
以免创建不必要的方法
-
由于逻辑不同的弹出窗口数量
-
我已经看到了这个问题,但我希望仍然有解决这个问题的方法!无需其他方法即可创建多个模态的任何其他解决方案或模态插件
标签: javascript vue.js