如何存储HTML并从数据库中检索HTML

问题描述 投票:0回答:2

我正在使用Vue.js作为前端和Node.js作为后端来制作博客应用。我在前端使用富文本编辑器(vue2-editor)为用户创建博客的内容。我想将该内容存储在数据库(MySQL)中并检索它。目前,我存储的任何内容都是使用普通HTML格式的goig。

<p><strong>This is Blog Heading</strong></p><p><br></p><p><u>This is underlined</u></p><p><br></p><p>This is start of the paragraph</p>

并且从数据库检索后,它也显示相同的内容。我需要实现哪些额外功能?

mysql vue.js vuejs2 vue-component rich-text-editor
2个回答
0
投票

使用v-html将其显示为html而不是字符串。

您可以在这里了解更多信息:

https://vuejs.org/v2/guide/syntax.html

示例:

<div v-html="htmlFromDb" />

0
投票

这是博客标题

带下划线的符号

这是本段的开头

© www.soinside.com 2019 - 2024. All rights reserved.