el-popconfirm(气泡确认框)的入门学习

el-popconfirm(气泡确认框)的入门学习

适用场景

删除按钮的再次确认可以用到气泡确认框

知识点

  1. title设置气泡确认框内容
  2. confirm-button-text设置确认按钮文本
  3. cancel-button-text设置取消按钮文本
  4. icon设置内容图标
  5. icon-color设置内容图标颜色
  6. @confirm设置确认按钮钩子
  7. @cancel设置取消按钮钩子
  8. slot='reference'指定气泡确认框显隐的按钮

效果图

在这里插入图片描述

代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>

<body>
    <div id='app'>
        <el-popconfirm title='确认删除???'
        confirm-button-text='Yes'
        cancel-button-text='No'
        icon='el-icon-delete'
        icon-color='red'
        @confirm='handleConfirm'
        @cancel='handleCancel'>
            <el-button slot='reference'>删除</el-button>
        </el-popconfirm>
    </div>
</body>

</html>
<script>
    new Vue({
        el: '#app',
        data() {
            return {

            }
        },
        methods: {
            handleConfirm(){
                console.log('confirm')
            },
            handleCancel(){
                console.log('cancel')
            }
        }
    })
</script>

官网

el-popconfirm学习官网

  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
要将el-popconfirm放入el-popover中使用,可以按照以下步骤进行操作: 1. 首先,在需要使用el-popover的地方添加el-popover组件,并设置相应的属性,例如触发方式、内容等。 2. 在el-popover的内容中,添加el-popconfirm组件,并设置相应的属性,例如标题、确认按钮文本等。 3. 在el-popconfirm中,可以使用el-button等组件作为触发按钮,点击触发按钮时会显示确认。 4. 在确认按钮的点击事件中,可以执行相应的逻辑操作。 下面是一个示例代码,演示了如何将el-popconfirm放入el-popover中使用: ```html <template> <div> <el-popover placement="top" title="Popover Title" trigger="click" content="Popover Content" > <el-button type="primary">Click me</el-button> <template slot="reference"> <el-popconfirm title="Are you sure to delete?" confirm-button-text="Yes" cancel-button-text="No" @confirm="handleConfirm" > <el-button type="danger">Delete</el-button> </el-popconfirm> </template> </el-popover> </div> </template> <script> export default { methods: { handleConfirm() { // 执行删除操作 console.log("Delete confirmed"); }, }, }; </script> ``` 在上述示例中,点击"Click me"按钮会触发el-popover的显示,同时在popover中显示了一个"Delete"按钮。当点击"Delete"按钮时,会弹出确认,点击确认按钮会执行`handleConfirm`方法,输出"Delete confirmed"。 希望以上信息能够帮助到你!如果有任何疑问,请随时提问。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

自律最差的编程狗

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值