From 0735b4452dbf41dfd671a121e035bcdfb7085e7b Mon Sep 17 00:00:00 2001 From: yutent Date: Wed, 2 Nov 2022 18:33:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=AF=E5=88=A0=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/index.js | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 419bb25..2ac437c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bytedo/fetch", - "version": "2.1.0", + "version": "2.1.1", "description": "全新的ajax封装。分2个版本, 一个基于XMLHttpRequest, 一个基于window.fetch", "main": "dist/index.js", "files": [ diff --git a/src/index.js b/src/index.js index cb4eaed..726f769 100644 --- a/src/index.js +++ b/src/index.js @@ -150,18 +150,19 @@ class _Request { /* -------------------------- 3»» 处理跨域 --------------------- */ try { + let crossDomain let $a = document.createElement('a') - $a.href = options.url + $a.href = options.url crossDomain = location.protocol !== $a.protocol || location.host !== $a.host $a = null - } catch (err) {} - if (crossDomain) { - if (options.credentials) { - this.xhr.withCredentials = true + if (crossDomain) { + if (options.credentials) { + this.xhr.withCredentials = true + } } - } + } catch (err) {} /* ------------- 4»» 根据method类型, 处理表单数据 ---------------- */