el-popconfirm(气泡确认框)的入门学习
适用场景
删除按钮的再次确认可以用到气泡确认框
知识点
title
设置气泡确认框内容confirm-button-text
设置确认按钮文本cancel-button-text
设置取消按钮文本icon
设置内容图标icon-color
设置内容图标颜色@confirm
设置确认按钮钩子@cancel
设置取消按钮钩子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>