简体   繁体   English

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

[英]How to save textarea multiline text to Cloud Firestore?

I have this textArea input field for blogPost text content that may contain multiline text, like:我有这个textArea输入字段,用于可能包含多行文本的blogPost文本内容,例如:

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;我将在带有white-space: pre-wrap;<p>标签内显示它(在我的应用程序中加载blogPosts时) white-space: pre-wrap;

How should I save this to Cloud Firestore?我应该如何将其保存到 Cloud Firestore?

What I've got so far:到目前为止我所得到的:

I'm thinking about saving as JSON.stringify(textareaValue);我正在考虑另存为JSON.stringify(textareaValue);

How can I do this?我怎样才能做到这一点? Any better options?还有更好的选择吗?

Cloud Firestore will store exactly what you send it. Cloud Firestore 将准确存储您发送的内容。 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.如果您在屏幕上渲染时需要字符串有所不同(例如将换行符转换为<br> ),那么您必须自己进行这些修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM