Javascript react中导入原型函数时出错
我正在使用React,希望从另一个文件中添加一些原型函数。 这个函数在我的nodejs项目中工作得很好,但是当我导入它以作出反应时,站点会出现以下错误 TypeError:注册表[name]。推送不是函数 registry.concat.reduce.onCreateRule protFile.jsJavascript react中导入原型函数时出错,javascript,prototype,Javascript,Prototype,我正在使用React,希望从另一个文件中添加一些原型函数。 这个函数在我的nodejs项目中工作得很好,但是当我导入它以作出反应时,站点会出现以下错误 TypeError:注册表[name]。推送不是函数 registry.concat.reduce.onCreateRule protFile.js // eslint-disable-next-line no-extend-native Object.prototype.MyCustomMethod = function() { r
// eslint-disable-next-line no-extend-native
Object.prototype.MyCustomMethod = function() {
return Object.keys(this).reduce((newObject, key) => {
// some logic
return newObject;
}, {});
};
module.exports = Object
reduxation.js
错误发生在之后
import lll from "./protFile"
或
我做错了什么
var lll = require("./protFile")