When vue,mavon-editor, is saved in the database, it is html, to take it out and how to convert it to markdown, as shown in the following figure and code.

< H2 > question < / H2 >

how to convert vue,mavon-editor, to markdown,

when saving it in the database is html, and then take it out.

clipboard.png

< H2 > Code < / H2 >
<mavon-editor v-model="content" @change="changeData" />
        changeData(value, render) {
            console.log(value);
            console.log(render);
            this.contentHtml = render;
        }
Mar.11,2022

since it is html, why should markdown, always feel superfluous, because in the end, markdown is also transformed into html


I think you can design two fields in the database, one field is used to store markdown format, the other is stored in html format, and you can use it respectively when using it,


is it there? I can't send private messages when I just registered.
I want to ask you a question. How can I get the value of mavon-editor? How to customize the upload button


 2html
html
save () {
      this.content.content = this.$refs.md.d_render //html
      this.content.textcontent = this.$refs.md.d_value //
      if (this.$route.params.id) {
        this.content._id = this.$route.params.id
        this.$axios.post('/api/updata', this.content).then(res => {
          this.content.content = res.data.data.textcontent
        })
      } else {
        this.$axios.post('/api/save', this.content).then(res => {
          this.content.content = res.data.data.textcontent
        });
      }
    }

I transfer it directly to base64 before upload, and then convert it back to the database from the front end when needed.


I think md should be stored in the database, because it is the original data, read it out and then render it into html to display


.

look at this https://blog.csdn.net/x_s_yangg/article/details/106663847

push me up!

Menu