在 webpack 中使用 whatwg-fetch

Using whatwg-fetch with webpack

whatwg-fetchnpm page 中说:

Importing will automatically polyfill window.fetch and related APIs:

import 'whatwg-fetch'

window.fetch(...)

在同一部分的下方

For use with webpack, add this package in the entry configuration option before your application entry point:

entry: ['whatwg-fetch', ...]

我用webpack.

我应该同时导入它并将其添加为条目,还是条目就足够了?

一个或另一个,它们无论如何都会产生相同的输出。我建议导入你的入口点,而不是在你的 webpack 配置上添加入口数组。