小程序 - 使用async出现regeneratorRuntime is not defined错误 不能使用async 和await 的解决方案
regeneratorRuntime
参考博客:小程序regeneratorRuntime is not defined 小程序中使用async函数
async await比Promise更好的解决异步操作问题,在小程序中直接使用会出现以下的错误提示
缺少了regeneratorRuntime这个模块,需要从外部引入
1.在新建的文件夹中执行 npm init ,生成package.json文件(一路回车就好)
2.执行 npm install regenerator
3.将node_modules文件夹下的regenerator-runtime文件夹复制到小程序项目中
4.在需要使用到async await的.js文件引入regenerator-runtime文件夹下的runtime.js文件
import regeneratorRuntime from '../../regenerator-runtime/runtime.js';
---------------------
作者:jnChen10
来源:CSDN
原文:https://blog.csdn.net/sinat_33184880/article/details/85533095
版权声明:本文为博主原创文章,转载请附上博文链接!