hinesboy / mavonEditor

mavonEditor - A markdown editor based on Vue that supports a variety of personalized features
http://www.mavoneditor.com/
MIT License
6.4k stars 917 forks source link

[Question] marvonEditor@next 局部引入出现报错 #723

Open rainym00d opened 2 years ago

rainym00d commented 2 years ago

💬 Questions and Help

在使用支持vue3的测试版时,我选择了更多引入方式里的方法3进行局部注册,但会出现 ReferenceError: sMd is not defined

我的浏览器是Chrome,系统是mac

我的文件结构如下:

  1. Editor.vue处于components文件夹中,写了以下代码:
<template>
     <div id="editor">
          <mavon-editor style="height: 100%"></mavon-editor>
     </div>
 </template>

<script>
    // Local Registration
    import { mavonEditor } from 'mavon-editor'
    import 'mavon-editor/dist/css/index.css'
    export default {
        name: 'editor',
        components: {
            mavonEditor
            // or 'mavon-editor': mavonEditor
        }
    }
</script>

<style>
    #editor {
        margin: auto;
        width: 80%;
        height: 580px;
    }
</style>
  1. Add.vue 处于views文件夹中,写了以下代码:
<template>
     <div id="main"></div>
</template>

<script>
import { createApp, h } from 'vue'
var editor = require('@/components/Editor.vue');
createApp({
     render: () => h(editor)
}).use(sMd).mount('#main');
</script>
wangsongc commented 2 years ago

Editor.vue中已经引入mavonEditor了,Add.vue不用再use, 修改成下面试试

<template>
     <div id="main"></div>
</template>

<script>
import { createApp, h } from 'vue'
import editor from '@/components/Editor.vue'
createApp({
     render: () => h(editor)
}).mount('#main');
</script>