imzbf / md-editor-v3

Markdown editor for vue3, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
https://imzbf.github.io/md-editor-v3
MIT License
1.6k stars 154 forks source link

markedHeading 无效 #51

Closed tech-xs closed 2 years ago

tech-xs commented 2 years ago

在仅预览模式下 这个函数是无效的 markedHeading 仅预览模式属性 previewOnly

<template>
  <Mgr>
    <md-editor class="body" v-model="mdText"
               @markedHeading="markedHeading"
               previewOnly/>
  </Mgr>
</template>

<script>
import Mgr from '@/components/mgr/Mgr'
import MdEditor from 'md-editor-v3';
import 'md-editor-v3/lib/style.css';
// import {getDocContent} from "@/api/doc/doc";

export default {
  name: "WebDoc",
  components: {Mgr, MdEditor},
  data() {
    return {
      mdText: '# AAAA'
    }
  },
  created() {
    // getDocContent('/web/webDoc').then(res => {
    //   this.mdText = res
    // })
  },
  methods:{
    markedHeading(text, level, raw){
      console.log('aaaaa')
      console.log(text)
      console.log(level)
      console.log(raw)
    }
  }
}
</script>
<style lang="less" scoped>
.body {
  margin-left: 50px;
  margin-right: 50px;
}
</style>
imzbf commented 2 years ago

抱歉,文档有点问题,请像下面这样使用:

<md-editor class="body" v-model="mdText" :markedHeading="markedHeading" preview-only />