vue项目 ueditor使用示例

简介

UEditor是由百度Web前端研发部开发的所见即所得富文本web编辑器,具有轻量,功能丰富,易扩展等特点。UEditor支持常见的文本编辑功能,如字体、颜色、大小、加粗、斜体、下划线、删除线等,同时还支持超链接、图片上传、表格编辑、代码段插入、全屏编辑等高级功能。此外,UEditor还支持自定义扩展,可以通过编写插件的方式进行扩展。UEditor广泛应用于各类Web产品中,如博客、论坛、内容管理系统等。

使用步骤

一,下载封装的ueditor包

https://download.csdn.net/download/u012551928/87934068

预览

https://chengmaofeng.gitee.io/preview/rich-text/#/ueditor

使用示例:

<template>
  <div>
    <vue-ueditor-wrap v-model="dataStr" :config="myConfig"></vue-ueditor-wrap>
    <el-button v-clipboard="dataStr" style="margin: 15px;float:right;" type="primary" @click="handleCopy">复制源代码</el-button>
  </div>
</template>
<script>
  import VueUeditorWrap from 'vue-ueditor-wrap'

  export default {
    components: { VueUeditorWrap },
    data() {
      return {// 编辑器
        dataStr: '我是渲染字段',
        myConfig: {
          // 编辑器不自动被内容撑高
          autoHeightEnabled: false,
          // 初始容器高度
          initialFrameHeight: 600,
          // 初始容器宽度
          initialFrameWidth: '100%',
          // 上传文件接口
          serverUrl: '',
          // UEditor 是文件的存放路径,
          UEDITOR_HOME_URL: '/ueditor/'
        }
      }
    },
    methods: {
      handleCopy(){
        console.log('复制', this.dataStr)
      }
    }
  }
</script>
<style lang="scss" scoped>

</style>

可以自行封装成组件!!👀️

总结

本文仅仅简单介绍了ueditor使用,更多富文本配置及使用方式,参考:http://fex.baidu.com/ueditor/#start-config

如果觉得有用欢迎点赞关注
有问题私信我!!~~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
为了在Vue项目使用UEditor,你需要先安装UEditor的npm包。你可以使用以下命令进行安装: ``` npm install vue-ueditor-wrap --save ``` 安装完成后,你可以在Vue组件中引入UEditor使用。下面是一个简单的示例: ```html <template> <div> <vue-ueditor-wrap :options="editorConfig" v-model="content"></vue-ueditor-wrap> </div> </template> <script> import VueUeditorWrap from 'vue-ueditor-wrap' export default { components: { VueUeditorWrap }, data() { return { content: '', editorConfig: { UEDITOR_HOME_URL: '/static/UEditor/', // UEditor资源文件的根目录 serverUrl: '/api/upload', // UEditor上传图片和文件的后端接口地址 toolbars: [ [ 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'insertorderedlist', 'insertunorderedlist', '|', 'link', 'unlink', 'anchor', '|', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'fullscreen' ] ], } } } } </script> ``` 这个示例中,我们首先在组件中引入了`vue-ueditor-wrap`组件。然后我们在`data`中定义了一个`content`变量来保存UEditor编辑器中的内容,并定义了一个`editorConfig`对象来配置UEditor。 最后,我们在模板中使用`vue-ueditor-wrap`组件,将它的`options`属性设置为我们定义的`editorConfig`对象,并使用`v-model`指令将编辑器中的内容绑定到`content`变量上。 当用户在UEditor中编辑内容时,`content`变量的值也会相应地更新。你可以在组件中使用`content`变量来获取编辑器中的内容,以便将其保存到后端或进行其他操作。 希望这个示例对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

成茂峰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值