Skip to content

Commit f631ff1

Browse files
committed
fix 因为fetch未被eslint识别,而使用window.fetch,结果使得fetch未能polyfill上,导致在IE、safiri上网页显示错误
1 parent 3778320 commit f631ff1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/services/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global Headers:false, fetch:false */
12
function checkStatus (response) {
23
if (response.status >= 200 && response.status < 300) {
34
return response
@@ -17,7 +18,7 @@ function parseText (response) {
1718

1819
export default {
1920
get (url, isJson = true, param = {}, headers = {}, host = process.env.sourcePath) {
20-
headers = new window.Headers(headers)
21+
headers = new Headers(headers)
2122
var query = []
2223
Object.keys(param).forEach((item) => {
2324
query.push(`${item}=${encodeURIComponent(param[item])}`)
@@ -30,11 +31,11 @@ export default {
3031
cache: 'default'
3132
}
3233
if (isJson) {
33-
return window.fetch(url, init)
34+
return fetch(url, init)
3435
.then(checkStatus)
3536
.then(parseJSON)
3637
} else {
37-
return window.fetch(url, init)
38+
return fetch(url, init)
3839
.then(checkStatus)
3940
.then(parseText)
4041
}

0 commit comments

Comments
 (0)