Dart - 运行项目不会加载dart文件,而不是在控制台中打印 [英] Dart - running a project does not load the dart file and not printing in the console

查看:231
本文介绍了Dart - 运行项目不会加载dart文件,而不是在控制台中打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在dart中创建了一个新的项目,并添加了一些代码,但是当我运行(我不管,如果我运行dart文件与运行在Dartium或如果Ctrl + R)的dart文件不显示我在main中创建的按钮,也在main()方法中我添加了一个print()以便在控制台中打印一条消息,但没有显示。

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.

另外:如果我使用Run as JavaScript按钮正常显示,这里是我正在做的:

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

1.-my html code:

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.-我的dart文件(忘记上面的代码都被注释)消息并创建按钮:

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.-我使用Run in Dartium绿色图标

4.-这就是我得到的,没有按钮

5.-没有打印消息

6.-也没有打印消息
< br>

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

我应该如何在dart中运行?感谢

How should I suppose to run in dart? thanks

推荐答案

我的猜测是你的Dartium的副本已过期。它只能工作60天,然后你需要升级它。

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.

升级到最新的代码会给你最新的Dartium并修复它。

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

这篇关于Dart - 运行项目不会加载dart文件,而不是在控制台中打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆