Dart - running a project does not load the dart file and not printing in the console

大城市里の小女人 提交于 2019-12-24 07:15:48

问题


I have created a new project in dart and added some code, but when I run (I doesn't matter if I run the dart file with "Run in Dartium" or if Ctrl + R) the dart file is not showing the button that I've create in the main, also in the main() method I've added a print() in order to print a message in the console, but nothing is showed.

Also: if I run with "Run as JavaScript" the button is showed normally, here is what I'm doing:

1.-my html code:

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>Capitulo9</title>
    <link rel="stylesheet" href="capitulo9.css">
  </head>
  <body>


    <script type="application/dart" src="capitulo9.dart"></script>
    <script src="packages/browser/dart.js"></script>
    capitulo9.dart

  </body>
</html>

2.-my dart file (forget the code from above everything is commented) I want to print the the message and create the button:

main() {

  print("I wish to print this in the console");

  var startButton = new Element.html("<button>Start</button>");
    document.body.children.add(startButton);
}

3.-I have run it with "Run in Dartium" and with the green icon
4.-That's what I get, no button
5.-no message printed
6.-also no message printed

How should I suppose to run in dart? thanks


回答1:


My guess is that your copy of Dartium expired. It only works for 60 days, and then you need to upgrade it.

I recently found that it didn't even show a message to tell you why it wasn't working (though I believe it's supposed to). I raised a bug about this; though there's been no repsonse so far.

Upgrading to the latest code would've given you the latest Dartium and fixed it.



来源:https://stackoverflow.com/questions/24975864/dart-running-a-project-does-not-load-the-dart-file-and-not-printing-in-the-con

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!