【发布时间】:2019-02-09 03:44:56
【问题描述】:
我将 React 与 Redux 一起使用,但我遇到了 IE 问题。仅在 IE 上不起作用。
当我只使用 react 构建应用程序时,它可以工作,所以我猜测它与 Redux 有关。它为应用返回 undefined 并且 redux-logger 显示此错误:
SCRIPT438:对象不支持属性或方法“assign”
我的 webpack:
const path = require("path");
const componentName = "contact-captain";
const publicFolderRelativePath = "../../../../public/js";
module.exports = {
output: {
path: path.resolve(__dirname, publicFolderRelativePath),
filename: `${componentName}.js`
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader"
}
}
]
}
};
package.json
{
"name": "temp",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"watch": "webpack -w --mode development --progress --color --display-error-details",
"build": "webpack --mode production"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.2",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.3.0",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0"
},
"dependencies": {
"axios": "^0.18.0",
"lodash": "^4.17.10",
"moment": "^2.22.2"
}
}
.babelrc
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [ "@babel/plugin-transform-object-assign"]
}
当我使用 babel-polyfill 时它可以工作,但我不能使用它,因为在加载 babel-polyfill 的页面上已经使用了它,所以它为那个不同的组件返回错误。
【问题讨论】:
标签: reactjs webpack redux babeljs