在vue3中MessageBoxshow-confirm-button=false如何设置
时间: 2024-04-30 22:24:25 浏览: 18
在 Vue 3 中,`MessageBox` 组件已经被移除,使用 `Dialog` 组件代替。要实现不显示确认按钮的效果,可以通过 `Dialog` 的 `confirmButtonText` 属性设置为空字符串来实现。
例如:
```
<template>
<div>
<button @click="showDialog">显示对话框</button>
<el-dialog
:visible.sync="dialogVisible"
title="提示"
:confirm-button-text="''"
>
<span>这是一条消息</span>
</el-dialog>
</div>
</template>
<script>
import { ref } from 'vue'
import { ElDialog } from 'element-plus'
export default {
components: { ElDialog },
setup() {
const dialogVisible = ref(false)
const showDialog = () => {
dialogVisible.value = true
}
return {
dialogVisible,
showDialog,
}
},
}
</script>
```
在上面的例子中,`confirm-button-text` 属性被设置为空字符串,这样就隐藏了确认按钮。