如何将 textarea 多行文本保存到 Cloud Firestore?

How to save textarea multiline text to Cloud Firestore?

我有这个 textArea 输入字段用于 blogPost 可能包含多行文本的文本内容,例如:

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

我会在带有 white-space: pre-wrap;

<p> 标签内显示它(在我的应用程序中加载 blogPosts 时)

我应该如何将其保存到 Cloud Firestore?

到目前为止我得到了什么:

我正在考虑保存为 JSON.stringify(textareaValue);

我该怎么做?还有更好的选择吗?

Cloud Firestore 将准确存储您发送的内容。如果您需要在屏幕上呈现时字符串有所不同(例如将换行符转换为 <br>),则您必须自己进行这些修改。