Integrate UEditor Plus with Vue 3
masterTo use UEditor Plus in a Vue 3 project:
- Install the wrapper:
npm i --save vue-ueditor-wrap@3.x. - Copy the
dist-mindirectory from UEditor Plus to your project'spublic/static/UEditorPlus/directory. - Register the plugin in
main.jsusing.use(VueUeditorWrap). - Use the
<vue-ueditor-wrap>component in your templates.
// main.js
import {createApp} from 'vue'
import App from './App.vue'
import VueUeditorWrap from 'vue-ueditor-wrap';
createApp(App).use(VueUeditorWrap).mount('#app')<!-- App.vue -->
<template>
<div>
<vue-ueditor-wrap v-model="content"
editor-id="editor"
:config="editorConfig"
:editorDependencies="['ueditor.config.js','ueditor.all.js']"
style="height:500px;"/>
</div>
</template>
<script setup>
import {ref} from 'vue';
const content = ref('<p>Hello UEditorPlus</p>');
const editorConfig = {
serverUrl: '/api/path/to/server',
UEDITOR_HOME_URL: '/static/UEditorPlus/',
UEDITOR_CORS_URL: '/static/UEditorPlus/',
}
</script>