当前位置: 首页 > news >正文

vue3引用vue-ueditor-wrap组件

参考文档:vue-ueditor-wrap - Vue + UEditor + v-model双向绑定Vue + UEditor + v-model双向绑定https://haochuan9421.github.io/vue-ueditor-wrap/#/home

1.安装组件

npm i vue-ueditor-wrap@3.0.8

2.下载 UEditor

下载链接:https://pan.baidu.com/s/1WEhVbXI_iHW8yU9O_z2hmQ?pwd=f9xo

放在public目录下

3.注册组件

main.ts

import VueUeditorWrap from 'vue-ueditor-wrap';
import { createApp } from "vue";
const app = createApp(App);
app.use(VueUeditorWrap)

4.封装组件

/src/components/ueditor/index.vue

<template>
    <vue-ueditor-wrap v-model="state.editorVal" :config="editorConfig" :editor-id="props.editorId" @ready="ueready"
        @input="handleInput" claas="ueditor-wrap"></vue-ueditor-wrap>
</template>
  
<script setup lang="ts" name="Ueditor">
import { ref, onMounted, reactive, watch, getCurrentInstance } from 'vue'

// 定义父组件传过来的值
const props = defineProps({
    editorId: {
        type: String,
        default: 'editor1'
    },
    // 双向绑定,用于获取 editor.getHtml()
    getHtml: String,
})

// 定义子组件向父组件传值/事件
const emit = defineEmits(['update:getHtml']);

const state = reactive({
    editorVal: props.getHtml,
});
const { proxy }: any = getCurrentInstance();
const editorConfig = {
    UEDITOR_HOME_URL: './UEditor/', // 访问 UEditor 静态资源的根路径,可参考常见问题1
}

function ueready(edt) {
    //WordPaster快捷键 Ctrl + V
    edt.addshortcutkey({
        "wordpaster": "ctrl+86"
    });
}
const handleInput = (val: string) => {
    // console.log("handleInput===", val);
    emit('update:getHtml', val);
};

watch(
    () => state.editorVal,
    (val) => {
        emit('update:getHtml', val);
    },
    {
        deep: true,
    }
);
</script>

<style scoped lang="scss"></style>

5.页面引用组件

<Ueditor editorId="Ueditor1" v-model:get-html="ruleForm.content"></Ueditor>
<Ueditor editorId="Ueditor2" v-model:get-html="ruleForm.wxcontent"></Ueditor>

import Ueditor from '/@/components/ueditor/index.vue';

components: {
	Ueditor
},

效果图


文章转载自:

http://O6hsphZE.Lxhny.cn
http://WuJolIIf.Lxhny.cn
http://P4oK2OVP.Lxhny.cn
http://tBb8t6yF.Lxhny.cn
http://J2OqM55H.Lxhny.cn
http://L3NRyuFT.Lxhny.cn
http://9K61LSIx.Lxhny.cn
http://O3TZPdpZ.Lxhny.cn
http://7s2SG5B3.Lxhny.cn
http://6kmOhhef.Lxhny.cn
http://TA2wETpT.Lxhny.cn
http://Fbq8buAZ.Lxhny.cn
http://LILLXDEn.Lxhny.cn
http://TjLQyQli.Lxhny.cn
http://PYoJ8CIB.Lxhny.cn
http://JdPRi4b4.Lxhny.cn
http://0O2eBDWR.Lxhny.cn
http://7AiCzLjU.Lxhny.cn
http://4MRKAAhF.Lxhny.cn
http://cE6exGAo.Lxhny.cn
http://m20AL9G6.Lxhny.cn
http://Cj3xQDNy.Lxhny.cn
http://inwIzq1c.Lxhny.cn
http://OPP1Hn6j.Lxhny.cn
http://yzTrXKbV.Lxhny.cn
http://TANOAx85.Lxhny.cn
http://hwgVzmHD.Lxhny.cn
http://YtPdbONA.Lxhny.cn
http://bhtPXSOr.Lxhny.cn
http://qtZJDf1S.Lxhny.cn
http://www.dtcms.com/a/29254.html

相关文章:

  • Log4j在Spring项目中的应用与实践
  • 钉钉多维表:数据管理与协作的新篇章
  • 数仓搭建(hive):DWB层(基础数据层)
  • 【核心算法篇九】《DeepSeek联邦学习:医疗数据隐私保护实战》
  • Spring IoC DI
  • 腿足机器人之十- SLAM地图如何用于运动控制
  • Compose 定制UI视图
  • Golang通过 并发计算平方 示例演示并发
  • 【Linux】Linux 文件系统——有关 inode 不足的案例
  • Golang实现简单的接口去重函数
  • Http升级为Https - 开发/测试服环境
  • MATLAB基础学习相关知识
  • 【Java】多线程和高并发编程(四):阻塞队列(上)基础概念、ArrayBlockingQueue
  • 深入理解IP地址与端口:网络通信的基石
  • 现代游戏UI架构深度解析——以UIController为核心的模块化界面管理系统
  • 华大MCU HC32F005端口GPIO控制失效问题
  • 在原有基础上的Python正则表达式终极指南,新增高级用法、复杂案例和底层原理分析
  • DApp 开发入门指南
  • 车载诊断数据库 --- 通用性诊断数据库ODX
  • ubuntu22.04桥接模式开代理
  • 改BUG:Mock测试的时候,when失效
  • 面试题之箭头函数和普通函数有什么区别?
  • 【AI】GitHub Copilot
  • 从【人工智能】到【计算机视觉】,【深度学习】引领的未来科技创新与变革
  • VScode 使用Deepseek又方便又好用的另一款插件
  • 掌握.NET Core后端发布流程,如何部署后端应用?
  • 【LeetCode】力扣刷题攻略路线推荐!适合新手小白入门~(含各类题目序号)
  • 2025年2月深度实测!DeepSeek、OpenAI o1、Gemini打造爆款应用及对比
  • 【Java场景题】MySQL死锁排查
  • 解决双系统开机显示gnu grub version 2.06 Minimal BASH Like Line Editing is Supported