How to save textarea multiline text to Cloud Firestore?

China☆狼群 提交于 2021-02-05 08:45:17

问题


I have this textArea input field for blogPost text content that may contain multiline text, like:

This is paragraph one.
(empty line)
This is paragraph two.

I will display it (when loading the blogPosts in my App) inside a <p> tag with white-space: pre-wrap;

How should I save this to Cloud Firestore?

What I've got so far:

I'm thinking about saving as JSON.stringify(textareaValue);

How can I do this? Any better options?


回答1:


Cloud Firestore will store exactly what you send it. If you need the string to be something different at the time you render it on screen (like converting newlines to <br>), then you will have to make those modifications yourself.



来源:https://stackoverflow.com/questions/56564761/how-to-save-textarea-multiline-text-to-cloud-firestore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!