vue中使用Element UI的$confirm 不执行确定按钮后的方法?

新手上路,请多包涵

在点击确认按钮的时候调后台的api进行删除操作。点击确定都跳到catch里面

 v.$confirm('此操作将永久删除该选民信息, 是否继续?', '温馨提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(async () => {
        await this.$api.apiList.deleteUser({
          user_id: userid[0].user_id,
        }).then((res) => {
          console.log(res);
        });
        v.$message.success('删除成功');
      }).catch(() => {
        v.$message.info('已取消删除');
      });
阅读 11k
1 个回答
promise(1).then(() => {
    // 1的成功
}, () => {
    // 1的错误
}).catch(() => {
    // '1的错误'抛出错误
    // '1的成功'抛出错误 
})

promise(1).then(() => {
    // 1的成功
}).catch(() => {
    // 1的错误
    // '1的成功'抛出错误
})

你的是第二中情况,要确认是不是 '1的成功'抛出的错误,很简单输出一下看进then了没有

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题