先进先出
This commit is contained in:
@@ -18,14 +18,20 @@ import {
|
||||
let timeout = 10000
|
||||
const request = config => {
|
||||
// 浏览器测试用
|
||||
const storageBaseUrl = 'http://' + getBaseUrl() + '/api';
|
||||
// const storageBaseUrl = 'http://' + getBaseUrl() + '/api';
|
||||
// 真机测试以及部署用
|
||||
//const storageBaseUrl = 'http://' + getBaseUrl();
|
||||
const storageBaseUrl = 'http://' + getBaseUrl();
|
||||
// 是否需要设置 token
|
||||
const isToken = (config.headers || {}).isToken === false
|
||||
config.header = config.header || {}
|
||||
|
||||
// 假设你使用的是PHP作为你的后端语言
|
||||
config.header['Access-Control-Allow-Origin']= '*'; // 允许任何源访问
|
||||
config.header['Access-Control-Allow-Methods']='GET, POST, OPTIONS'; // 允许的HTTP方法
|
||||
config.header['Access-Control-Allow-Headers']= 'X-Requested-With'; // 允许的HTTP头
|
||||
if (getToken() && !isToken) {
|
||||
config.header['Authorization'] = 'Bearer ' + getToken()
|
||||
|
||||
}
|
||||
// get请求映射params参数
|
||||
if (config.params) {
|
||||
@@ -44,9 +50,10 @@ const request = config => {
|
||||
dataType: 'json'
|
||||
}).then(response => {
|
||||
let [error, res] = response
|
||||
// console.log('token:','Bearer ' + getToken());
|
||||
// console.log('token:','Bearer ' + getToAccess-Control-Allow-Originken());
|
||||
// console.log('request:',storageBaseUrl + config.url,response);
|
||||
if (error) {
|
||||
console.log(error)
|
||||
toast('后端接口连接异常')
|
||||
reject('后端接口连接异常')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user