vue 确认删除的提示框

image-20201104161736428

image-20201104161820820

需要在element-ui中按需导入

Vue.prototype.$message = Message
Vue.prototype.$confirm = MessageBox.confirm

然后在删除方法中加入下面代码就行

/*提示消息*/
      const confirmResult = await this.$confirm('此操作将永久删除该职位, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err)
      /*如果用户确认打印confirm,如果用户取消显示cancel*/
      if (confirmResult !== 'confirm') {
        return this.$message.info('已取消删除!')
      }
      // console.log('确认了删除')
原文地址:https://www.cnblogs.com/ma1998/p/13926550.html