Dart中的多行字符串 [英] Multi-lines string in Dart
问题描述
我仍在研究Dart。我只想将.dart中定义的字符串输出到html。我查看了 http://c.dart-examples.com/learn/variables上的文档/ strings
I'm still working on Dart. I just want to output my string defined in .dart to my html. I look into the documentation on http://c.dart-examples.com/learn/variables/strings
我知道我需要使用。
当我打印我的查询,我得到了很好的结果,但是当我用html输出时,它们是并排的。
When I print my query, I got the good result, but when I output it in html, They are side to side.
有:
.dart:
var symbole = """
*
***
*****
*******
*********""";
var element03 = query('#exercice03');
element03.innerHTML = symbole;
print(symbole);
}
打印给我的正是我在var符号中设置的内容,但是在我的HTML中,我得到了这样的信息:
The Print give me exactly what I set into my var symbole BUT, in my HTML i got this:
My html is :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HelloWorld</title>
<link rel="stylesheet" href="HelloWorld.css">
</head>
<body>
<div id="container">
<p class="question">Exercice : Pritn the * : <span id="exercice03"></span></p>
</div>
<script type="application/dart" src="web/HelloWorld.dart"></script>
<script src="https://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
</body>
</html>
我不明白为什么在输出html中没有得到与打印相同的结果dart编辑器,有人可以帮我解决这个问题吗?
I don't understand why in my output html I dont get the same result as my Print in my dart editor, can some one help me to figure this out?
推荐答案
我不确定是否在这里关注您-您要这个吗?
I'm not sure if I follow you here -- do you want this?
var symbole = """
*<br />
***<br />
*****<br />
*******<br />
*********<br />""";
var element03 = query('#exercice03');
element03.innerHTML = symbole;
我刚刚添加了换行符
因此,正如Matt B所说, print()
的输出格式与浏览器上的HTML格式不同。
So as Matt B said, the output of print()
is differently formatted than HTML on the browser.
这篇关于Dart中的多行字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!