我从coreui vue模板中获得了以下代码,
<b-modal title="Modal title" class="modal-success" v-model="successModal" @ok="successModal = false" ok-variant="success">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</b-modal>`
结果如下:
https://i.stack.imgur.com/8qPLJ.png
问题: 如何在该模式的页脚中编辑两个按钮(取消和确定)?
答案 0 :(得分:1)
对于任何在这个问题上磕磕绊绊的人,这里有另一个答案。
<CModal title="Delete scraper?" :show.sync="dangerModal" color="danger">
By deleting this scraper, you will delete all the jobs and results that
are related to this scraper.<br><br>
<span class="font-weight-bold">Are you sure you would want to delete this scraper?</span>
<div slot="footer" class="w-100">
<CButton style="border-radius: .2rem; color: white;" color="danger" class="ml-1 mr-1 float-right" @click="dangerModal = true">
<i class="fas fa-trash"></i>
</CButton>
<CButton style="border-radius: .2rem; color: white;" color="danger" class="ml-1 mr-1 float-right" @click="dangerModal = true">
<i class="fas fa-trash"></i>
</CButton>
</div>
</CModal>
通过添加带有插槽名称的 div 元素。
或
你可以这样做,这样更干净、更容易:
<CModal title="Delete scraper?" :show.sync="dangerModal" color="danger">
By deleting this scraper, you will delete all the jobs and results that
are related to this scraper.<br><br>
<span class="font-weight-bold">Are you sure you would want to delete this scraper?</span>
<template #footer>
<CButton @click="dangerModal = false" color="danger">Discard</CButton>
<CButton @click="dangerModal = false" color="success">Accept</CButton>
</template>
</CModal>
只需使用带有您要使用的插槽的主题标签的模板元素。在本例中,我使用 #footer 来更改模式的页脚。
插槽名称在官方 CoreUI Vue 文档 here 中列出。
答案 1 :(得分:0)
我知道。 这是一个插槽,
您可以像下面那样放置页脚插槽
{{1}}
答案 2 :(得分:0)
通过隐藏页脚删除按钮,以所需的方式添加按钮。 在按钮上,我们使用右浮动类将按钮指向右侧。 示例:
<template>
<div>
<b-button @click="showModal">
Open Modal
</b-button>
<b-modal ref="myModalRef" hide-footer title="Using Component Methods">
<div class="d-block text-center">
<h3>Alteration</h3>
</div>
<b-btn class="float-right" @click="hideModal">Test</b-btn>
</b-modal>
</div>
</template>
<script>
export default {
methods: {
showModal () {
this.$refs.myModalRef.show()
},
hideModal () {
this.$refs.myModalRef.hide()
}
}
}
</script>