fix: 修复白屏的问题

pull/32/head
954270063@qq.com 2021-06-30 22:47:50 +08:00
parent d173a4092a
commit ac3c08ad7b
2 changed files with 28 additions and 26 deletions

View File

@ -184,7 +184,7 @@ axios.get(
非全平台兼容的属性只会在平台支持的情况下生效。
| 参数 | 类型 | 默认值 | 说明 | 全平台兼容 |
| :---------------- | :------------------------ | :------------------------------------------------------------------------------------ | :----------------- | :--------- |
| :---------------- | :-----------------------: | :----------------------------------------------------------- | :----------------- | :--------- |
| adapter | Function | [查看](https://github.com/early-autumn/axios-miniprogram/blob/master/src/defaults.ts) | 自定义适配器 | 是 |
| baseURL | String | | 基础地址 | 是 |
| url | String | | 请求地址 | 是 |
@ -575,3 +575,6 @@ axios("/user")
// 请求失败
// axios => axios.interceptors.request => config.transformRequest => config.paramsSerializer => config.adapter => config.validateStatus => config.transformResponse => config.errorHandler => axios.interceptors.response => catch
```

View File

@ -23,15 +23,15 @@ export function buildURL(
return generateURL(url, paramsSerializer(params));
}
const combineREG = /(?<!:)\/{2,}/g;
const combineREG = /([^:])\/{2,}/g;
export function combineURL(baseURL = '', url: string): string {
const separator = '/';
const replaceStr = `$1${separator}`;
return `${baseURL}${separator}${url}`.replace(combineREG, separator);
return `${baseURL}${separator}${url}`.replace(combineREG, replaceStr);
}
const dynamicREG = /\/?(:([a-zA-Z_$][\w-$]*))\/??/g;
export function dynamicInterpolation(url: string, sourceData?: any): string {
if (!isPlainObject(sourceData)) {
return url;
@ -43,7 +43,6 @@ export function dynamicInterpolation(url: string, sourceData?: any): string {
}
const absoluteREG = /^([a-z][a-z\d+\-.]*:)?\/\//i;
export function isAbsoluteURL(url: string): boolean {
return absoluteREG.test(url);
}