某些浏览器在严格模式下不支持 Const 声明

Const declarations are not supported in strict mode on certain browsers

当我 运行 我的应用程序在 iOS iPhone 6 模拟器(或我的物理 iPad2)中时,我收到此错误:

SyntaxError: Unexpected keyword 'const'. Const declarations are not supported in strict mode.
=> reactBoilerplateDeps.dll.js:4088 

这导致 is-in-browser 模块包含在 jss:

export const isBrowser = typeof window === "object"
    && typeof document === 'object'
    && document.nodeType === 9;

export default isBrowser;

我正在使用这些软件包:

我该如何纠正这个问题?也许 transform-es2015-block-scoping 插件符合 ?

该应用程序在我的 物理 iPhone 6 和桌面浏览器上运行良好,但在我的 iPad2 上运行不正常。

根据 Can I Use,此问题已在 [iOS] Safari 10 中修复,因此您可以告诉 运行 遇到此问题的人他们的浏览器不可用不支持,他们应该更新它,但这确实不是一个好的解决方案。

另外,注意当twig.js hit this issue, their fix was to declare with the var keyword instead of const, so perhaps you should submit a bug report to is-in-browser关于这个的时候。

尝试查看使用 var 关键字而不是 const 是否适合您也是一个好主意,方法是编辑您找到 export const isBrowser ... 的文件以替换constvar。如果您决定提交错误报告,此信息将有所帮助,如果它确实有效,您可以使用您的修复创建他们存储库的分支,并提交拉取请求。

看起来 is-in-browser 不是使用正确的 babel 设置构建的。您可以尝试去 node_modules/is-in-browser 和 运行 npm run build 重建它。