【发布时间】:2017-04-07 09:49:13
【问题描述】:
我目前正在尝试构建一个与 Google Progressive Web Apps 规范兼容的网络应用程序。为此,我将 Angular 与基于 Dart 和 Polymer 的 Web 组件一起使用,而不是 Angular 组件。到目前为止,一切都按预期工作。为了使应用能够使用 Service-Worker API 离线,我使用了以下 dart 库:https://github.com/isoos/service_worker
使用 Polymer 或 Service-Worker 都可以正常工作,但结合使用booth 会在应用启动时退出并出现错误。
这是我的 AppComponent 启动例程:
// ... other imports
import 'package:service_worker/window.dart' as sw; // <-- import alone causes the error
Future main() async {
await initPolymer(); // <-- causes the error in combination with the import above
bootstrap(AppComponent);
if (sw.isNotSupported) {
print('ServiceWorkers are not supported.');
return;
}
//... initializing service worker
}
即使我没有初始化Service-Worker也会出现错误,导入Service-Worker模块就足以导致错误。
构建应用程序没有任何错误。
我是 Dart 以及 Polymer 和 Angular 生态系统的新手,我收到的错误消息对我没有多大帮助:
Uncaught Error: NoSuchMethodError: method not found: js_helper.dart:1742 'h' (J.Q(...).h is not a function)
at Object.J.H (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:9747:15)
at http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:10559:1584
at Isolate.e.(anonymous function) (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:10608:15)
at Object.yK (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:9291:22)
at http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:9282:10
at yM.a (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:2612:72)
at yM.dart.yM.$2 (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:2828:24)
at y9.dart.y9.$1 (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:2824:31)
at xM.bi (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:3767:40)
at xk.$0 (http://127.0.0.1:8080/index.bootstrap.initialize.dart.js:3167:16)
您能否给我一个提示,什么可能导致错误以及如何解决它?我非常想使用 Polymer 组件而不是普通的 Angular 组件,但我需要 Service-Worker 来支持离线缓存。
【问题讨论】:
标签: angularjs polymer dart service-worker progressive-web-apps