我正在尝试使用GitHub上的一个名为“SimpleBar”的插件GitHub SimpleBar,但在下载脚本并查看simple.js脚本后,它似乎出现了一个错误“SyntaxError:import declarations Mays only Account at top level of a module”
在simplebar.js文件的顶部有一些导入代码行:
import scrollbarWidth from 'scrollbarwidth'
import debounce from 'lodash.debounce'
import './simplebar.css'
如果我在浏览器调试器中查看,我会看到一个错误:“SyntaxError:import declarations Mays only Account at top level of a module”。
有没有人试图给我们这个插件。
非常感谢您抽出时间。
我在Firefox(FF58)上得到了这个。我用以下方法解决了这个问题:
about:config
dom.modulescripts.enabled
设置为true
来源:mozilla上的导入页面(参见浏览器兼容性)
从“./mylib.js”导入*
更多的例子,这篇博文很好。