WAService.js:3 thirdScriptError
regeneratorRuntime is not defined;at pages/dome1/dome1 page test function
ReferenceError: regeneratorRuntime is not defined
at http://127.0.0.1:9973/appservice/pages/dome1/dome1.js:47:50
at e.test (http://127.0.0.1:9973/appservice/pages/dome1/dome1.js:85:6)
at e.<anonymous> (http://127.0.0.1:9973/appservice/__dev__/WAService.js:15:4257)
at e.a (http://127.0.0.1:9973/appservice/__dev__/WAService.js:14:31107)
at K (http://127.0.0.1:9973/appservice/__dev__/WAService.js:14:25691)
at Function.<anonymous> (http://127.0.0.1:9973/appservice/__dev__/WAService.js:14:27280)
at http://127.0.0.1:9973/appservice/__dev__/WAService.js:15:647
at http://127.0.0.1:9973/appservice/__dev__/WAService.js:6:8176
at e.(anonymous function) (http://127.0.0.1:9973/appservice/__dev__/WAService.js:3:31751)
at d (http://127.0.0.1:9973/appservice/appservice:1100:8304)
let start = async function () {
try{
that.write(“start”);
await sleep(3000)
that.write(“end”);
}catch(err){
console.log(err)
}
}
start();
已解决!
小程序开发中由于 es6 至少 ios 9.1 不支持,所以如果已经在项目中使用了较多了es6或必须使用es6,则需要勾选 es6 转 es5,才能解决前述兼容问题。但若有使用 async await 会报 regeneratorRuntime is not defined 错误。解决方法如下:
下载 facebook 的 regenerator 库
取 regenerator-master/packages/regenerator-runtime 目录中的 runtime.js 文件放入你的项目中
在你有使用 async await 的文件前面引入这个 runtime.js 文件即可,引入代码如: const regeneratorRuntime = require('../../utils/runtime.js');
就这样,解决了!