我在为生产构建 javascript 文件时发现了这个问题,我再次测试了网站。在开发环境我无法重现。 我在我的 SinglePageApplication、npm 和 gulp 构建工具上使用 react 和 react-redux。
package.json:
"react": "~16.0.0",
"react-chartjs-2": "^2.6.4",
"react-dom": "~16.0.0",
"react-dropzone": "^4.1.3",
"react-popper": "^0.7.3",
"react-redux": "~4.4.0",
版本
react -v : 16.3.0
react-redux -v : 4.4.9
Gulp 命令
npm -i
gulp production
我从浏览器收到一条错误消息:
react-redux.min.js? 3b99:1 Uncaught
ReferenceError: g is not defined
at a (react-redux.min.js?3b99:1)
at a (react-redux.min.js?3b99:1)
at react-redux.min.js?3b99:1
最佳答案
我 2 天前在我的项目中遇到了同样的问题,没有接触代码,只构建了代码。
是版本 4.4.9 的 minifier react-redux.min 中的一个普遍问题;我建议在 package.json 中放入一个 react-redux
: '4.4.8'
这个问题有一个 issue ticket 但他们关闭了它,我希望他们能重新打开并尝试修复 4.4.9 版本 https://github.com/reactjs/react-redux/issues/904
关于javascript - react-redux - ReferenceError : g is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49816919/