富文本初始化

点击查看代码
import '@wangeditor/editor/dist/css/style.css' // 引入 css
import { onBeforeUnmount, ref, shallowRef, onMounted } from 'vue'
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'

//wangEditor5 初始化开始
// 编辑器实例,必须用 shallowRef
const editorRef = shallowRef()

const mode: 'default' // 或 'simple'


const editorConfig = {MENU_CONF:{} }
//图片上传配置
editorConfig.MENU_CONF['uploadImage']={
  hearder:{
    token: data.user.token,
  },
  server: baseUrl + '/files/wang/upload',
  fieldName: 'file'
}

// 组件销毁时,也及时销毁编辑器
onBeforeUnmount(() => {
  const editor = editorRef.value
  if (editor == null) return
  editor.destroy()
})

const handleCreated = (editor) => {
  editorRef.value = editor // 记录 editor 实例,重要!
}
//wangEditor5 初始化结束
posted @ 2025-04-06 15:17  雨花阁  阅读(9)  评论(0)    收藏  举报