• <tfoot id='B1O8H'></tfoot>
      <bdo id='B1O8H'></bdo><ul id='B1O8H'></ul>

    <small id='B1O8H'></small><noframes id='B1O8H'>

    <legend id='B1O8H'><style id='B1O8H'><dir id='B1O8H'><q id='B1O8H'></q></dir></style></legend>
    1. <i id='B1O8H'><tr id='B1O8H'><dt id='B1O8H'><q id='B1O8H'><span id='B1O8H'><b id='B1O8H'><form id='B1O8H'><ins id='B1O8H'></ins><ul id='B1O8H'></ul><sub id='B1O8H'></sub></form><legend id='B1O8H'></legend><bdo id='B1O8H'><pre id='B1O8H'><center id='B1O8H'></center></pre></bdo></b><th id='B1O8H'></th></span></q></dt></tr></i><div id='B1O8H'><tfoot id='B1O8H'></tfoot><dl id='B1O8H'><fieldset id='B1O8H'></fieldset></dl></div>

      1. 在旧浏览器上使用 Fetch 的 ReactJS

        时间:2023-10-02

                  <tbody id='D41wE'></tbody>
              1. <legend id='D41wE'><style id='D41wE'><dir id='D41wE'><q id='D41wE'></q></dir></style></legend>

              2. <tfoot id='D41wE'></tfoot>
                  <bdo id='D41wE'></bdo><ul id='D41wE'></ul>

                  <small id='D41wE'></small><noframes id='D41wE'>

                  <i id='D41wE'><tr id='D41wE'><dt id='D41wE'><q id='D41wE'><span id='D41wE'><b id='D41wE'><form id='D41wE'><ins id='D41wE'></ins><ul id='D41wE'></ul><sub id='D41wE'></sub></form><legend id='D41wE'></legend><bdo id='D41wE'><pre id='D41wE'><center id='D41wE'></center></pre></bdo></b><th id='D41wE'></th></span></q></dt></tr></i><div id='D41wE'><tfoot id='D41wE'></tfoot><dl id='D41wE'><fieldset id='D41wE'></fieldset></dl></div>
                • 本文介绍了在旧浏览器上使用 Fetch 的 ReactJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Webpack 和 Babel 实现 React JS.但是,我无法让 Fetch 与 IE 11 一起使用.

                  我的 .babelrc 文件中有以下内容:

                  <代码>{预设":[env",stage-0",react"]}

                  以及我的 webpack.config.js 文件中的以下内容:

                  var webpack = require('webpack');var path = require('path');var DIST_DIR = path.resolve(__dirname, 'dist');var SRC_DIR = path.resolve(__dirname, 'src');变量配置 = {入口: {捆: ['babel-polyfill',SRC_DIR + '/app/index.js',]},输出: {路径:DIST_DIR + '/public/js',文件名:'bundle.js'},模块: {装载机:[{测试:/.jsx?$/,包括:SRC_DIR,加载器:'babel-loader'}]}};module.exports = 配置;

                  根据我的理解,实现 babel-preset-env、stage-0 和 babel-polyfill 应该允许将 Fetch API 转换为旧浏览器可以理解的东西.我还有什么遗漏的吗?

                  解决方案

                  fetch 不是 EcmaScript 的一部分,而是 web 平台 的一部分.Babel 只是一个编写最新 Javascript 的编译器.如果你想在旧版浏览器中使用 fetch 你需要一个像 this one

                  Fetch API:阅读更多p>

                  I am implementing React JS, with Webpack and Babel. However, I am having trouble getting Fetch to work with IE 11.

                  I have the following in my .babelrc file:

                  {
                    "presets" : ["env", "stage-0", "react"]
                  }
                  

                  and the following in my webpack.config.js file:

                  var webpack = require('webpack');
                  var path = require('path');
                  
                  var DIST_DIR = path.resolve(__dirname, 'dist');
                  var SRC_DIR = path.resolve(__dirname, 'src');
                  
                  var config = {
                    entry: {
                      bundle: [
                        'babel-polyfill',
                        SRC_DIR + '/app/index.js',
                      ]
                    },
                    output: {
                      path: DIST_DIR + '/public/js',
                      filename: 'bundle.js'
                    },
                    module: {
                      loaders: [
                        {
                          test: /.jsx?$/,
                          include: SRC_DIR,
                          loader: 'babel-loader'
                        }
                      ]
                    }
                  };
                  
                  module.exports = config;
                  

                  From my understanding implementing babel-preset-env, stage-0, and babel-polyfill should have allowed for the Fetch API to be transpiled into something older browsers could understand. Is there something else that I am missing?

                  解决方案

                  fetch isn't part of EcmaScript but its part of the web platform. Babel is only a compiler to write the latest Javascript. If you want to use fetch in older browsers you need a polyfill like this one

                  Fetch API: read more

                  这篇关于在旧浏览器上使用 Fetch 的 ReactJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在函数中使用设置间隔和获取 下一篇:使用 json (body: raw) POST 数据时总是失败

                  相关文章

                      <bdo id='ojx2G'></bdo><ul id='ojx2G'></ul>
                  1. <tfoot id='ojx2G'></tfoot>

                    1. <i id='ojx2G'><tr id='ojx2G'><dt id='ojx2G'><q id='ojx2G'><span id='ojx2G'><b id='ojx2G'><form id='ojx2G'><ins id='ojx2G'></ins><ul id='ojx2G'></ul><sub id='ojx2G'></sub></form><legend id='ojx2G'></legend><bdo id='ojx2G'><pre id='ojx2G'><center id='ojx2G'></center></pre></bdo></b><th id='ojx2G'></th></span></q></dt></tr></i><div id='ojx2G'><tfoot id='ojx2G'></tfoot><dl id='ojx2G'><fieldset id='ojx2G'></fieldset></dl></div>
                      <legend id='ojx2G'><style id='ojx2G'><dir id='ojx2G'><q id='ojx2G'></q></dir></style></legend>

                    2. <small id='ojx2G'></small><noframes id='ojx2G'>