Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs SCRIPT438:对象没有';t支持属性或方法';分配';_Reactjs_Webpack_Redux_Babeljs - Fatal编程技术网

Reactjs SCRIPT438:对象没有';t支持属性或方法';分配';

Reactjs SCRIPT438:对象没有';t支持属性或方法';分配';,reactjs,webpack,redux,babeljs,Reactjs,Webpack,Redux,Babeljs,我正在使用React with Redux,我在IE上遇到问题。只有在IE上不起作用 当我只使用react构建应用程序时,它是有效的,所以我猜它是使用Redux的。它正在返回未定义的应用程序,并且redux记录器显示此错误: SCRIPT438:对象不支持属性或方法“assign” 我的网页: const path = require("path"); const componentName = "contact-captain"; const publicFolderRelativePath

我正在使用React with Redux,我在IE上遇到问题。只有在IE上不起作用

当我只使用react构建应用程序时,它是有效的,所以我猜它是使用Redux的。它正在返回未定义的应用程序,并且redux记录器显示此错误:

SCRIPT438:对象不支持属性或方法“assign”

我的网页:

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"
  }
}
B.法律改革委员会

{
  "presets": ["@babel/preset-env", "@babel/preset-react"],
  "plugins": [ "@babel/plugin-transform-object-assign"]
}
当我使用babel polyfill时,它可以工作,但我不能使用它,因为在加载babel polyfill的页面上,它已经被使用了,因此它会返回不同组件的错误。

考虑添加到您的.babelrc中,以使其工作。

添加它对我有帮助

  if (typeof Object.assign != 'function') {
        Object.assign = function(target) {
            'use strict';
            if (target == null) {
                throw new TypeError('Cannot convert undefined or null to object');
            }

            target = Object(target);
            for (var index = 1; index < arguments.length; index++) {
                var source = arguments[index];
                if (source != null) {
                    for (var key in source) {
                        if (Object.prototype.hasOwnProperty.call(source, key)) {
                            target[key] = source[key];
                        }
                    }
                }
            }
            return target;
        };
    }
if(type of Object.assign!=“function”){
Object.assign=函数(目标){
"严格使用",;
if(target==null){
抛出新的TypeError('无法将未定义或null转换为对象');
}
目标=对象(目标);
for(var index=1;index
此解决方案还解决了IE11在加载带有Facebook聊天插件的页面时抛出的错误。添加代码后,FB聊天开始在IE上工作。谢谢@olga_babic。