浏览模式: 普通 | 列表
2月, 2024 | 1

uniapp封装网络请求

[ 2024-02-23 09:05:57 | 作者: admin ]

const install = (Vue, vm) => {
  let devServer = 'http://121.168.0.101:1601';
  Vue.prototype.$u.http.setConfig({
    baseUrl: devServer, //请求地址
    webviewUrl: server,
    loadingText: '努力加载中~',
    loadingTime: 800,
    // 设置自定义头部content-type
    header: {
      'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
    }
    // ......
  });
  


  // 请求拦截部分,如配置,每次请求前都会执行
  Vue.prototype.$u.http.interceptor.request = (config) => {
...

阅读全文…
1