使用 Dart 'js' 进行模块化 js包裹

发布于 2025-01-16 22:01:08 字数 432 浏览 4 评论 0原文

使用 dart interop js 包 我正在努力寻找一种使用多个 js 文件的方法(或者使用 CommonJS或 ES6 语法)。似乎只要在外部 js lib 文件中使用 import 语句,就会出现错误:

NoSuchMethodError:尝试调用非函数,例如 null: 'dart.global.someJsMethod'

当使用 @JS() 语法调用任何方法时,会抛出 。我尝试过使用 webpack 生成单个 js 文件,但错误仍然存​​在。

我是否只需接受这一点并手动合并到一个 js 文件中以删除所有 import 语句?或者我在飞镖参考资料中遗漏了一些秘方?

With the dart interop js package I am struggling to find a way of using multiple js files (either with CommonJS or ES6 syntax). It appears that as soon as an import statement is used within an external js lib file, an error:

NoSuchMethodError: tried to call a non-function, such as null:
'dart.global.someJsMethod'

is thrown when calling any methods with the @JS() syntax. I have tried using webpack to generate a single js file, but the error remains.

Do I just accept this and manually merge into one js file to get rid of all import statements? Or am I missing some secret sauce in my dart references?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文