1***@qq.com
1***@qq.com
  • 发布:2022-07-28 10:01
  • 更新:2022-07-28 10:01
  • 阅读:621

[vite] [plugin:uni:pre] Unexpected identifier

分类:uni-app
axiosConfig.ts内容  
// 环境的切换  
// const pubUrl = '';  
// if (process.env.NODE_ENV === 'development') {  
//   // 开发环境  
//   pubUrl = '';  
// } else if (process.env.NODE_ENV === 'debug') {  
//   pubUrl = ''; // 调试环境  
// } else if (process.env.NODE_ENV === 'production') {  
//   pubUrl = ''; // 生产环境  
// }  
// 允许当前axios携带cookie  
export const http = <T = any>(options: any) => new Promise((resolve, reject) => {  
  // eslint-disable-next-line no-undef  
  uni.request({  
    // 官方文档说是默认携带cookie(h5环境),实际体验并非如此  
    withCredentials: true,  
    url: options.url,  
    method: options.method || 'get',  
    data: options.data || {},  
    header: options.header || {  
      // 'content-type': 'application/x-www-form-urlencoded'  
      // #ifdef !H5 只在非h5的小程序添加下面的  cookie  
      // eslint-disable-next-line no-undef  
      cookie: uni.getStorageSync('shiro'),  
      // #endif  
    },  
    // 请求成功的回调,可以在方法做返回状态码的判断。也可以直接返回resolve  ==》success: resolve,fail:reject  
    success: (res) => {  
      const data = {} as T;  
      console.log(data);  

      console.log(res);  
      resolve(res);  
    },  
    // 请求失败的回调,可以在方法。反馈用户、提示用户,也可以直接返回reject  ==》success: resolve,fail:reject  
    fail: (err) => {  
      reject(err);  
    },  
  });  
});  
2022-07-28 10:01 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复