问题:getContent(),为同步,里面调接口,会报错
解决:用 jq 调接口
核心代码:
步骤:
- 安装 jQ npm i jquery --save
- 导入$ import $ from “jquery”;
- $.ajax…
代码:
getContent(e) {
const model = e.item.getModel();
let response = {};
$.ajax({
method: “get”,
url: “http://localhost/dev-api/dgw/dl/neo4j/merge/table/tasks”,
data,
headers: { Authorization: "Bearer " + getToken() },
async: false,
success: function (res) {
response = res;
},
});
let htmls = ...
retuen htmls;
}