gpt4 book ai didi

javascript - 如何在源于grails服务的textarea中显示换行符?

转载 作者:行者123 更新时间:2023-12-02 15:49:23 25 4
gpt4 key购买 nike

我正在制作一个grails-angular应用程序,并且从grails服务中获取了字符串。但是,当我尝试将其实现到textarea中时,它不会显示新行。

在grails中,我试图用替换“\ n”
但它似乎不起作用。

服务器端

...
def a = MyDomain.get(myid)
String result = a.detail.replace('\\n','
 
')
...

ANGULAR
...
$http.get('myController/getDetail?myId=' + id, vm.getConfig).
then(function(data) {
vm.textareaModel = data;
}
...

HTML
<textarea rows="5" ng-model='myScope.textareaModel' name='textarea'></textarea>

样本输入
this is a sample\n apple pen pineapple pen\n

输出
this is a sample&#013;&#010; apple pen pineapple pen&#013;&#010;

最佳答案

尝试将div与contenteditable属性一起使用。

关于javascript - 如何在源于grails服务的textarea中显示换行符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42131269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com