在我的新项目中,我遇到了 Firefox 的问题。首先我想说的是,在 Opera、Chrome 和 Edge 中它运行良好,但只有在其中一种浏览器中才会出现意外错误。
我正在使用本地 JSON 和一些对象,然后在 JS 中我使用
// Import JSON Insurance Data
import insurances from './insurances.json' assert {type: 'json'}
然后
insurances.forEach(e => {myCode});
就像我所说的,它通常可以工作,但在 Firefox 的控制台中却出现错误:
SyntaxError: unexpected token: identifier
浏览器指向这一行:
import insurances from './insurances.json' assert {type: 'json'}
仅查看 MDN 文档,Firefox 不支持导入断言。
我也很困惑它为什么能在 Opera 中为你工作,因为目前它被列为不受支持,与 Firefox 一样。
在此处查看更多信息:MDN 导入浏览器兼容性