The Dart app runs fine in Dartium, but I would like to convert it to JS.
C:\dart-sdk\bin\dart2js --out=test.js main.dart
generates JS from:
import 'dart:html';
void main() {
querySelector('#myid').text = 'Wake up, sleepy head!';
}
Then I add it to the <head>
:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<p id="myid">hello</p>
</body>
</html>
But when I run it in Firefox, it doesn't work. It shows only "Hello" on the page. What am I doing wrong?
The Dart app runs fine in Dartium, but I would like to convert it to JS.
C:\dart-sdk\bin\dart2js --out=test.js main.dart
generates JS from:
import 'dart:html';
void main() {
querySelector('#myid').text = 'Wake up, sleepy head!';
}
Then I add it to the <head>
:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<p id="myid">hello</p>
</body>
</html>
But when I run it in Firefox, it doesn't work. It shows only "Hello" on the page. What am I doing wrong?
Share Improve this question edited May 29, 2017 at 18:26 Badacadabra 8,5377 gold badges31 silver badges54 bronze badges asked Apr 27, 2015 at 19:58 SulimanSuliman 1,5093 gold badges13 silver badges19 bronze badges1 Answer
Reset to default 5dart2js
is usually not the straight-forward way to generated JS from Dart.
Normally you just run pub build
in your project directory.
Ensure you have your pubspec.yaml
configured properly csp: true
(for Chrome apps Using Polymer in a Dart Chrome App, Chrome App CSP violation after Dart/Polymer transform/pile to JavaScript)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744106852a4558763.html
评论列表(0条)