如何将textarea多行文本保存到Cloud Firestore? [英] How to save textarea multiline text to Cloud Firestore?

查看:37
本文介绍了如何将textarea多行文本保存到Cloud Firestore?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 blogPost 文本内容提供了这个 textArea 输入字段,该文本内容可能包含多行文本,例如:

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.

(在我的应用程序中加载 blogPosts 时),我将在带有 white-space:pre-wrap; <

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

如何将其保存到Cloud Firestore?

How should I save this to Cloud Firestore?

目前为止我所拥有的:

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

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

How can I do this? Any better options?

推荐答案

Cloud Firestore将完全存储您发送的内容.如果您需要在显示屏幕时将字符串更改为其他字符(例如将换行符转换为< br> ),那么您将必须自己进行修改.

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.

这篇关于如何将textarea多行文本保存到Cloud Firestore?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆