收藏
回答

为什么在开发者工具使用async报错,但真机调试能成功运行?

js文件

import { getSetting,chooseAddress,openSetting} from "../../utils/asyncWx.js";
import regeneratorRuntime from '../../lib/runtime/runtime.js';
async address(){
    //获取收货地址
    const res1=await getSetting();
    const scopeAddress=res1.authSetting["scope.address"];
    if(scopeAddress===true||scopeAddress===undefined){
      const res2=await chooseAddress();
      console.log(res2);
    }else{
      await openSetting();
      const res2=await chooseAddress();
      console.log(res2);
    }
  }

asyncWx.js

export const getSetting=()=>{
  return new Promise((resolve,reject)=>{
    wx.getSetting({
      success(result) => {
        resolve(result);
      },
      fail(err) => {
        reject(err);
      }
    });
  })
}
export const chooseAddress=()=>{
  return new Promise((resolve,reject)=>{
    wx.chooseAddress({
      success(result) => {
        resolve(result);
      },
      fail(err) => {
        reject(err);
      }
    });
  })
}
export const openSetting=()=>{
  return new Promise((resolve,reject)=>{
    wx.openSetting({
      success(result) => {
        resolve(result);
      },
      fail(err) => {
        reject(err);
      }
    });
  })
}

报错

Error: module "@babel/runtime/helpers/interopRequireDefault.js" is not defined

回答关注问题邀请回答
收藏

3 个回答

登录 后发表内容