Vue3 中如何使用 UEditor 富文本编辑器
目前还没有官方发布的 Vue3 版本的 UEditor 插件,但是你仍然可以使用 Vue2 版本的 UEditor 插件来在 Vue3 项目中使用 UEditor。
首先,你需要安装 UEditor 插件。你可以通过以下命令来安装:
npm install vue-ueditor-wrap --save
然后,在你的 Vue 组件中引入 UEditor 插件,并且在mounted生命周期钩子中初始化 UEditor。
<template>
<div>
<vue-ueditor-wrap ref='editor' @ready='onEditorReady'></vue-ueditor-wrap>
</div>
</template>
<script>
import VueUeditorWrap from 'vue-ueditor-wrap'
export default {
name: 'MyComponent',
components: {
VueUeditorWrap
},
mounted() {
this.$refs.editor.initEditor()
},
methods: {
onEditorReady() {
console.log('UEditor is ready')
}
}
}
</script>
这样,你就可以在 Vue3 项目中使用 UEditor 了。你可以根据 UEditor 的官方文档来调用 UEditor 的 API 来实现你的需求。
原文地址: https://www.cveoy.top/t/topic/p3nC 著作权归作者所有。请勿转载和采集!