Jac*_*ina 5 mysql rich-text-editor vue.js vue-component vuejs2
我正在使用博客应用Vue.js的前端和Node.js的的后端。
我在前端使用富文本编辑器 ( vue2-editor ) 供用户创建博客内容。我想将该内容存储在数据库 (MySQL) 中并检索它。目前,我存储的任何内容都是纯 HTML。
<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>
Run Code Online (Sandbox Code Playgroud)
从数据库中检索后,它呈现为字符串而不是 HTML
我怎样才能让它正确显示 HTML?
用于v-html
将其显示为 html 而不是字符串。
你可以在这里读更多关于它的内容:
https://vuejs.org/v2/guide/syntax.html
例子:
<div v-html="htmlFromDb" />
Run Code Online (Sandbox Code Playgroud)