微信公众号ios10.1 版本白屏问题
真机调试IOS 10.1.x的版本不支持fetch 所以一直loading显示白屏。
其他设备都没问题。 所以用主要属性window.fetch用来判断是否支持fetch 属性
import {
baseUrl
} from './env' export default async(url = '', data = {}, type = 'GET', method = 'fetch') => {
type = type.toUpperCase();
url = baseUrl + url; if (type == 'GET') {
let dataStr = ''; //数据拼接字符串
Object.keys(data).forEach(key => {
dataStr += key + '=' + data[key] + '&';
}) if (dataStr !== '') {
dataStr = dataStr.substr(0, dataStr.lastIndexOf('&'));
url = url + '?' + dataStr;
}
} if (window.fetch && method == 'fetch') {
let requestConfig = {
credentials: 'include',
method: type,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': localStorage.getItem('token'),
},
mode: "cors",
// cache: "force-cache"
} if (type == 'POST') {
Object.defineProperty(requestConfig, 'body', {
value: JSON.stringify(data)
})
} try {
const response = await fetch(url, requestConfig);
const responseJson = await response.json();
return responseJson
} catch (error) {
throw new Error(error)
}
} else {
return new Promise((resolve, reject) => {
let requestObj;
if (window.XMLHttpRequest) {
requestObj = new XMLHttpRequest();
} else {
requestObj = new ActiveXObject;
} let sendData = '';
if (type == 'POST') {
sendData = JSON.stringify(data);
} requestObj.open(type, url, true);
requestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
requestObj.setRequestHeader("Accept","application/json");
requestObj.setRequestHeader("Content-Type","application/json");
requestObj.setRequestHeader("Authorization",localStorage.getItem('token'));
requestObj.send(sendData); requestObj.onreadystatechange = () => {
if (requestObj.readyState == 4) {
if (requestObj.status == 200) {
let obj = requestObj.response
if (typeof obj !== 'object') {
obj = JSON.parse(obj);
}
resolve(obj)
} else {
reject(requestObj)
}
}
}
})
}
}
微信公众号ios10.1 版本白屏问题的更多相关文章
- vue解决IOS10低版本白屏问题
一.方案一 在build文件的webpack.prod.conf.js文件添加以下代码 new UglifyJsPlugin({ uglifyOptions: { compress: { warnin ...
- 微信公众号支付java版本
回调函数 @RequestMapping("/toPay") public String toPay(HttpServletRequest request, HttpServlet ...
- Nodejs微信公众号开发
概览 key value 项目名称 node微信公众号开发 项目描述 使用node编写接口,前后端分离获取签名数据 开发者 leinov 发布日期 2018-11-07 仓库 github地址 安装& ...
- 基于搜狗搜索的微信公众号爬虫实现(C#版本)
Author: Hoyho Luo Email: luohaihao@gmail.com Source Url:http://here2say.me/11/ 转载请保留此出处 本文介绍基于搜狗的微信公 ...
- JAVA版开源微信管家—JeeWx捷微3.2版本发布,支持微信公众号,微信企业号,支付窗、小程序
JeeWx捷微3.2微信企业号升级版本发布^_^ JeeWx捷微V3.2——多触点管理平台(支持微信公众号,微信企业号,支付窗.小程序) JeeWx捷微V3.2.0版本引入了更多新特性,支持微信公 ...
- JeeWx捷微3.1小程序版本发布,支持微信公众号,微信企业号,支付窗——JAVA版开源微信管家
支持小程序,JeeWx捷微3.1小程序版本发布^_^ JeeWx捷微V3.1——多触点小程序版本管理平台(支持微信公众号,微信企业号,支付窗) JeeWx捷微V3.1.0版本紧跟微信小程序更新,在 ...
- JAVA版开源微信管家—JeeWx捷微3.1小程序版本发布,支持微信公众号,微信企业号,支付窗
支持小程序,JeeWx捷微3.1小程序版本发布^_^ JeeWx捷微V3.1--多触点小程序版本管理平台(支持微信公众号,微信企业号,支付窗) JeeWx捷微V3.1.0版本紧跟微信小程序更新,在原有 ...
- 微信公众号接口类(PHP版本)
[项目需求] 通过微信提供的接口,实现微信公众号与后端的应用程序数据交互.消息响应等功能. [项目疑难点] 理解接口工作方式,统一接口API,响应速度.安全性等 [代码举例] WeixinAp ...
- JAVA开源微信管家平台——JeeWx捷微V3.3版本发布(支持微信公众号,微信企业号,支付窗)
JeeWx捷微V3.3版本紧跟微信小程序更新,在原有多触点版本基础上,引入了更多的新亮点:支持微信公众号.微信企业号.支付宝服务窗等多触点开发:采用微服务框架实现,可插拔可集成,轻量级开发:对小程序的 ...
随机推荐
- DZY Loves Math
DZY Loves Math 对于正整数 $n$,定义 $f(n)$ 为 $n$ 所含质因子的最大幂指数. 例如 $f(1960)=f(2^3 * 5^1 * 7^2)=3, f(10007)=1, ...
- 源码分析笔记Vector
概述 继承抽象类AbStractList,实现接口List.RandomAccess.Cloneable以及序列化接口默认容量大小为10,扩容增量为0,扩容为原容量的2倍如设置的增量大于0,则扩容为( ...
- C++ allocator类学习理解
前言 在学习STL中containers会发现C++ STL里定义了很多的容器(containers),每一个容器的第二个模板参数都是allocator类型,而且默认参数都是allocator.但是a ...
- centos7运行yum报如下提示:Run "yum repolist all" to see the repos you have
centos7运行yum报如下提示: There are no enabled repos. Run "yum repolist all" to see the repos you ...
- 面试题:实现strcpy,strlen,strcmp,strcat,memcpy 之c-style字符串
哪里可以看到c库函数的源码? gnu的c运行库glibc,但是源码的实现却是复杂的,需要考虑效率,stlen源码分析. c-style字符串有个约定,以空字符结尾,即 '\0' . ' }; &quo ...
- java 重新学习 (七)
一.mysql的InnoDB通过建立行级索确保事务完整性.,并以Oracle风格的共享锁来处理select语句.系统默认存储为InnoDB. 二. -- mysql 创建表 CREATE TABLE ...
- python类与对象
1. class命名规范:首字母大写,驼峰命名法 2. class 里面函数括号里面带(self)说明这是一个实例,调用实例方法需要用实例调用 class Teacher: def test_1 ...
- Groovy学习:第二章 Groovy语言的关键特征
1. 断言Assertion断言:用于判断预期的条件是否为真.例子:def list = [1,2,'x']assert list.size()==32. AST转换期使用的注释AST转换的注释:Gr ...
- python-opencv实现简单的车牌定位
车牌定位的原理:https://blog.csdn.net/relocy/article/details/78705662 训练好的分类器:https://github.com/zeusees/Hyp ...
- 一、spring的基本认识
Spring的认识 Spring是一个开放源代码的设计层面框架,它解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用 Spring是于2003 年兴起的一个轻量级的J ...