elementui 点击按钮弹出对话框
·
可以使用 Element UI 的 Dialog 组件来实现点击按钮弹出对话框的效果。
首先,在你的 template 中添加一个 Dialog 组件,并为其指定一个唯一的 id:
<template>
<el-dialog :visible.sync="dialogVisible" title="提示" width="30%">
对话框内容
</el-dialog>
</template>
然后,在你的 script 中添加一个变量来控制 Dialog 的可见性:
<script>
export default {
data() {
return {
dialogVisible: false,
};
},
};
</script>
最后,在你的 template 中的按钮元素上绑定一个点击事件,在事件处理函数中更改 dialogVisible 的值来控制 Dialog 的可见性:
<template>
<el-button @click="dialogVisible = true">点击弹出对话框</el-button>
<el-dialog :visible.sync="dialogVisible" title="提示" width="30%">
对话框内容
</el-dialog>
</template>
这样,当用户点击按钮时,Dialog 就会弹出,再次点击按钮或者在 Dialog 上点击关闭按钮时,Dialog 就会消失。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)