这是我有的MXML
<mx:Text id="name" styleName="textStyle" maxWidth="400"></mx:Text>
然后在同一个文件中我有:
<mx:Script>
<![CDATA[
private function init():void
{
name.text = data.string;
}
]]>
</mx:Script>
data.string
来自数据库,它包含以下内容:
"This is a string 'n with two lines."
我也试过这个:
"This is a string with two lines."
它们都没有在flex中创建新行——它们都以'n
和
的形式呈现在屏幕上。
如何使用来自数据库的字符串创建新行?
如果我在代码中像这样键入'n
,它就会起作用:
name.text = "test 'n test";
但如果我做CCD_ 5,即使CCD_。
我想你可以在这个网站上找到你想要的东西。
http://www.switchonthecode.com/tutorials/flex-php-tutorial-transmitting-data-using-json
如果我在来自数据库的字符串上运行它,它就会工作:
string.split("''n").join("'n");
或者您可以使用String.replace:
string.replace(/''n/g,''n')