this.$confirm(
'此操作将删除文件','提示',{
confirmButtonText: 'OK',
cancelButtonText: 'Cancel',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
点击OK按钮,调用then方法指定的内容,点击cancel按钮,调用catch方法指定的内容;如果then中的方法在运行过程中抛出错误,也会被catch方法捕获。