Dart js-interop not working if .dart file isn'

2019-08-12 04:12发布

问题:

After announcing new strategy for Dart, i decided to change include from

<script type="application/dart" src="/dart/script.dart"></script>

to

<script type="text/javascript" src="/dart/script.dart.js"></script>

But in that case js-interop seems broken. dart:js.context is empty. Is there any workarounds for this?

回答1:

It looks like you are missing this script tag:

<script data-pub-inline src="packages/browser/dart.js"></script>

There is also an open issue to fix this http://dartbug.com/23005