Ajax请求怎么样才能在前端弹出错误提示?

我不确定完整的上下文是什么,但我认为你可以这样做:

import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";

try {
  // ...
} catch (e) {
  popupAjaxError(e);
}

// 或者
ajax("...") // 某个函数
  .then(() => {
    // ...
  })
  .catch(popupAjaxError);
1 个赞