<p>El propio request.js de dva no es compatible con ie11, lo que indica que Promise no está definido</p>

Creado en 7 nov. 2016  ·  4Comentarios  ·  Fuente: dvajs/dva

const headers = { headers:{'Content-Type': 'application/x-www-form-urlencoded'}};
const cookie = {credentials: 'include'};

const baseUrl = 'http://localhost:8088/sjyzx-oauth/';

/**
 * Requests a URL, returning a promise.
 *
 * <strong i="5">@param</strong>  {string} url       The URL we want to request
 * <strong i="6">@param</strong>  {object} [options] The options we want to pass to "fetch"
 * <strong i="7">@return</strong> {object}           An object containing either "data" or "err"
 */
export default function request(url, options) {
  return fetch(baseUrl + url, Object.assign({},options, headers, cookie))
    .then(checkStatus)
    .then(parseJSON)
    .then((data) => ({ data }))
    .catch((err) => ({ err }));
}

Disculpe, ¿es imposible para mí establecer dos encabezados de solicitud? No tengo ningún problema para usar otros navegadores, o puedo cambiar la solicitud en request.js a ajax o Axios, ¿afectará el modelo?

uncaught at anonymous
at takeEvery(auth/login, undefined) 
at anonymous 
Error: ReferenceError: “Promise”未定义
question

Todos 4 comentarios

Simplemente agregue un polyfill de Promise y no habrá ningún problema con otras bibliotecas ajax.

@lincenying Creo que está encapsulado en dva / fetch, ¿cómo agregarlo?

¿Quieres seguir usando fetch o usar otras bibliotecas?
Si desea continuar usando fetch, cite el polyfill en el archivo de entrada,
Si desea utilizar otras bibliotecas ajax, simplemente ignórelas ...
Así es como uso axios
https://github.com/lincenying/mmf-blog-dva/blob/master/src/utils/request.js

si usa fetch, debe npm i promise-polyfill -S

request.js agrega este código

importar Promise de 'promise-polyfill'
if (! window.Promise) {
window.Promise = Promesa;
}

¿Fue útil esta página
0 / 5 - 0 calificaciones