const myInit = {
method: 'GET',
mode: 'same-origin',
credentials: 'same-origin',
cache: 'default'
};
fetch(url, myInit).then(res => {
const contentType = res.headers.get("Content-Type");
// 根据返回contentType,处理是json,还是下载文件
if (contentType.toLowerCase() == "application/json;charset=utf-8") {
res.json().then(data => {
alert(data.success);
});
} else if (contentType.toLowerCas
fetch将返回值进行对应类型的转换
最新推荐文章于 2024-05-05 15:15:00 发布