使用vue-ueditor-wrap 开发文本编辑器

介绍:这里主要说明在vue2.0中怎么使用vue-ueditor-wrap编辑器

  1. 使用命令下载插件
   cnpm install vue-ueditor-wrap -S
  1. 下载源码放到static文件夹中
   https://pan.baidu.com/s/1QP-7J043ct6ihMEiJN0cAQ
  1. 在组件中引入使用
<template>
  <div id="app">
     <vue-ueditor-wrap v-model="msg" :config="myConfig"></vue-ueditor-wrap>
     <button @click='getmsg'>获取</button>
     <div v-html='divHtml'></div>
  </div>
</template>
<script>
import VueUeditorWrap from 'vue-ueditor-wrap'
export default {
  name: 'App',
    created() {
    
  },
  components:  {VueUeditorWrap},
  data() { 
    return {
      divHtml:'',
      msg: '',
      myConfig: {
      // 编辑器不自动被内容撑高
      autoHeightEnabled: false,
      // 初始容器高度
      initialFrameHeight: 240,
      // 初始容器宽度
      initialFrameWidth: '100%',
      // 上传文件接口
      serverUrl: 'http://xxx:xxx',
      // UEditor 资源文件的存放路径
      UEDITOR_HOME_URL: '/static/UEditor/'
    }
    }
  },
  mounted() {
   
  },
  methods: {
     getmsg(){
       this.divHtml=this.msg
     }
  }
}
</script>

问题:

上传视频显示上传地址有误和提交后视频显示空白的问题

解决上传地址显示有误:

  1. 找到ueditor.all.js文件,搜索me.commands[“insertvideo”]
// 将html.push(creatInsertStr( vi.url, vi.width || 420,  vi.height || 280, id + i, null, cl, 'image'));替换为
html.push(creatInsertStr( vi.url, vi.width || 420,  vi.height || 280, id + i, null, cl, 'video'));
  1. 找到ueditor.config.js文件,搜索whiteList
// 在img中添加_url
img: ['src', 'alt', 'title', 'width', 'height', 'id', '_src', '_url','loadingclass', 'class', 'data-latex']
// video后面添加代码
source: ['src', 'type'],
embed: ['type', 'class', 'pluginspage', 'src', 'width', 'height', 'align', 'style', 'wmode', 'play', 'autoplay', 'loop', 'menu', 'allowscriptaccess', 'allowfullscreen', 'controls', 'preload'],
iframe: ['src', 'class', 'height', 'width', 'max-width', 'max-height', 'align', 'frameborder', 'allowfullscreen']
  1. 找到dialogs/video/video.js 文件,搜索function createPreviewVideo
//将
$G("preview").innerHTML = '<div class="previewMsg"><span>'+lang.urlError+'</span></div>'+
        '<embed class="previewVideo" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
            ' src="' + conUrl + '"' +
            ' width="' + 420  + '"' +
            ' height="' + 280  + '"' +
            ' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" >' +
        '</embed>';
// 替换为
$G("preview").innerHTML = '<video class="previewVideo" controls="controls" src="'+conUrl+'" style="width:420;height:280 "></video>';

解决上传视频显示空白:

// 找到ueditor.all.js和ueditor.all.min.js文件将一下代码删除
application/x-shockwave-flash
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
为了禁止vue-ueditor-wrap文本编辑器的编辑功能,你可以在使用组件的地方加上一个属性来禁用编辑。根据引用和引用中的代码,你可以在main.js和App.vue中添加以下代码: 在main.js中: ``` import VueUeditorWrap from 'vue-ueditor-wrap' Vue.component('vue-ueditor-wrap', { ...VueUeditorWrap, props: { disabled: { type: Boolean, default: false } }, mounted: function() { if (this.disabled) { this.$refs.ueditor.setDisabled() } } }) new Vue({ render: h => h(App), }).$mount('#app') ``` 在App.vue中: ``` <template> <div id="app"> <VueUeditorWrap :disabled="true"></VueUeditorWrap> </div> </template> <script> import VueUeditorWrap from 'vue-ueditor-wrap' export default { components: { VueUeditorWrap } } </script> ``` 这样设置之后,vue-ueditor-wrap文本编辑器就会被禁用,用户将无法编辑其中的内容。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [vue-ueditor-wrap百度富文本的使用](https://blog.csdn.net/qq_52883064/article/details/129875979)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [vue项目引入vue-ueditor-wrap文本编辑器](https://blog.csdn.net/weixin_45966674/article/details/123498254)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

努力让自己的选择变得正确

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

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

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

打赏作者

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

抵扣说明:

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

余额充值