我注意到了我並不打算使用的行爲。我有一個<textarea>
,如果我可以輸入一些文字,如下所示。如何在角度輸入中保留換行符
some content
some other content
yet another content
當我保存這個文本轉換成JSON對象並存儲起來,我得到的是:
"value" : "some content some other content yet another content"
另外,我有時會得到這樣的:
"value" : "some content
some other content
yet another content"
我想我已經期待接收是:
"value" : "some content \n
some other content \n
yet another content"
因此,我可以用與輸入相同的方式呈現內容。
但這似乎打破了我的JSON.parse(string)
。 我在輸入模型中使用AngluarJS。
編輯:
你是如何保存textarea的文本? –
我將它保存在一個對象中。 const data = {text:$ scope.text}然後我將它發送到我的服務器,它將它存儲在重新思考數據庫中。是嗎?它有幫助嗎? –
它給JavaScript中的錯誤? (如果是,那麼這是一個問題)...現在,如果_problem_是因爲你正在從控制檯複製到網站,你可以用引號替換引號''' –