我试图从 firebase 数据库中提取 markdown 字符串,然后使用react-markdown 将其渲染到组件中。但 Markdown 字符串无法正确显示。我认为问题是由于从新行开始。
我试图声明我在其中放置 markdown 的变量。有用。 在组件中创建的 markdown 字符串
但是从 firebase 数据库中提取的 markdown 字符串。它显示不正确。 从 firebase 数据库中提取的 markdown 字符串
这是我的代码
export default function BlogTemplate() {
const { id } = useParams();
useFirestoreConnect([
{
collection: "communications",
doc: id
}
]);
const post = useSelector(
state =>
state.firestore.data.communications &&
state.firestore.data.communications[id]
);
if (post) {
const input =
"# This is a header\n\nAnd this is a paragraph \n\n # This is header again"; // this is a markdown …Run Code Online (Sandbox Code Playgroud) 我正在使用Swift制作应用程序,而我正在使用Firebase Firestore.Firestore是一个数据库,它包含一些我放入的字符串UILabel.我的一些叮咬,我使用新的行命令(或\n).所以我的一些字符串看起来像这样:
"This is line one\nThis is line two\nThis is line three"
Run Code Online (Sandbox Code Playgroud)
但是,无论何时检索到该字符串,它都是addetoto UILabel并且看起来像这样......
这是第一行\n这是第二行\n这是第三行
......应该是这样......
这是第一行
这是第二行
这是第三行
我假设这\n不适用于来自数据库的字符串?我试过双重逃避\\n.有人有解决方法吗?
这是我正在使用的代码......
database.collection("songs").whereField("storyTitle", isEqualTo: "This is the story header").getDocuments { (snapshot, error) in
for document in (snapshot?.documents)! {
self.storyBodyLabel.text = (document.data()["storyBody"] as? String)!
}
}
Run Code Online (Sandbox Code Playgroud)