iOS-8 的 Promise 支持问题?
我看了 3.08 的更新文档,里面提到了更为全面的 es6 接口支持,当时看到的表格,Promise 的 iOS8 下没有打叉的应该是支持了。
但是今天发现在 iOS 8 中的 Promise 依然为 null。
是我哪里设置有误么?
我看了 3.08 的更新文档,里面提到了更为全面的 es6 接口支持,当时看到的表格,Promise 的 iOS8 下没有打叉的应该是支持了。
但是今天发现在 iOS 8 中的 Promise 依然为 null。
是我哪里设置有误么?
app.js 代码
App({
/**
* 程序异常
* @param err
*/
onError(err) {
console.error(err);
},
});
pages/index/index.js 代码
Page({
onShow(){
this.init().then(() => {
this.setData({app: 'ok'});
})
},
init(){
return new Promise((resolve, reject) => {
setTimeout(() => {
this.setData({ok: resolve.toString()})
resolve();
}, 3000)
});
}
})
pages/index/index.wxml
<view>{{ok}}</view>
<view>{{app}}</view>
模拟器结果
123
ok
手机iPhone6 plus ios8.3(12F70) 微信版本6.5.8
结果
123
ES6 -> ES5 为Babel自己手动转换
手机上小程序开调试模式 微信闪退
Babel后代码如下
"use strict";
/**
* 初始化小程序APP
*/
App({
/**
* 程序异常
* @param err
*/
onError: function onError(err) {
console.error(err);
}
});
'use strict';
Page({
onShow: function onShow() {
var _this = this;
this.init().then(function () {
_this.setData({ app: 'ok' });
});
},
init: function init() {
var _this2 = this;
return new Promise(function (resolve, reject) {
setTimeout(function () {
_this2.setData({ ok: 123 });
resolve();
}, 3000);
});
}
});
补充一下,最开始我关闭了 微信开发者工具 的工具栏 es6转es5,使用的是 babel 的转写,没有使用 polyfill。在 iOS 8 下 Promise 为 null。后来我开启了 es6转es5,效果还是一样。