【发布时间】:2015-12-04 22:15:24
【问题描述】:
我将数据存储在一个 YAML 文件中,该文件是在特定日期从 textarea(html 页面)接收到的。
在 YAML 中它以这种格式存储:
09_09_2015: ! "hello this is sireesha\n 1.some information \n2.some information"
当我从 YAML 获取这些数据并将其显示在文本区域中时,它显示为:
"hello this is sireesha\n 1.some information \n2.some information"
我怎样才能克服这个问题并将此文本显示为
hello this is sireesha
1.some information
2.some information
在文本区域中?
【问题讨论】:
-
如果是 javascript 将
\\n替换为\r\n。像这样:TextareaElement.value = TextareaElement.value.replace("\\n", "\r\n");。我不知道红宝石 -
您尝试过什么,您使用哪种语言将其呈现到文本区域?
-
@suresh 我认为
<br>不会在 textarea 中工作。会吗? -
@TechJS 对不起..是的,它不起作用..我需要这样的东西 .
-
在jquery中绘制数据前,将数据存入一个变量,使用variable.replace("\n","");