这篇帖子主要是想介绍一下如何在vue3+ts中安装wangEditor编辑器,其实如何安装引入使用在官网里面已经介绍过。点击可查看vue3使用wangeditor。
主要也是我在实际练习过程中,模仿练习的过程中而碰到的问题。
一,安装
yarn add @wangeditor/editor
# 或者 npm install @wangeditor/editor --save
yarn add @wangeditor/editor-for-vue@next
# 或者 npm install @wangeditor/editor-for-vue@next --save
二,vue组件中引入
<script>
import '@wangeditor/editor/dist/css/style.css' // 引入 css
import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
// 编辑器实例,必须用 shallowRef
const editorRef = shallowRef()
// 内容 HTML
const valueHtml = ref('<p>hello</p>')
const toolbarC