【问题标题】:The line break doesn't work in the firestore换行符在 Firestore 中不起作用
【发布时间】:2021-08-19 09:26:55
【问题描述】:

我使用 vue 3 和 firestore。

我在写的时候,虽然按回车键换行,但只能写空格。

在火库中

这是我的代码。

<div class="form-group">
  <textarea class="form-control" cols="30" rows="10" v-model="content" required></textarea>
</div>

await db.collection('forms').add(
      {
        title: title.value, content: content.value, createdAt, updatedAt, uid, name, views
      }
    )

如何使用换行符?

【问题讨论】:

  • 你是说textEnteredBeforeSendingToFirestore !== textReceivedFromFirestore 吗?

标签: javascript vue.js google-cloud-firestore firebase-console


【解决方案1】:

Firestore 中的换行符按原样保留,问题在于 Firestore 中的渲染机制被设计为忽略换行符以保留 Firestore 文档的结构。

如果您下载文档快照并将文本呈现在文本区域框内,您可以看到这一点,对于网站,您可能需要将换行符替换为网络安全的替代方案,例如 &lt;br /&gt;

【讨论】:

    【解决方案2】:

    我刚刚添加了 style="white-space:pre-line" 就可以了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多