当前位置:Gxlcms > 数据库问题 > nodejs+mongodb+vue前后台配置ueditor

nodejs+mongodb+vue前后台配置ueditor

时间:2021-07-01 10:21:17 帮助过:16人阅读

‘../static/UE/ueditor.all.min.js‘ import ‘../static/UE/lang/zh-cn/zh-cn.js‘ import ‘../static/UE/ueditor.parse.min.js‘

值得一提的是需要将ueditor.config.js文件中的目录配置为放置该插件的目录:

window.UEDITOR_HOME_URL = "/static/UE/"

 

技术分享图片

然后在组件中配置好就可以了

我的UE.vue组件:

<template>
  <script :id=id type="text/plain"></script>
</template>

<script>
  export default {
    name: ‘UE‘,
    data () {
      return {
        editor: null
      }
    },
    props: {
      defaultMsg: {
        type: String
      },
      config: {
        type: Object
      },
      id: {
        type: String
      },
    },
    mounted() {
      const _this = this;
      this.editor = UE.getEditor(this.id, this.config); // 初始化UE
      this.editor.addListener("ready", function () {
        _this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。
      });
    },
    methods: {
      getUEContent() { // 获取内容方法
        return this.editor.getContent()
      }
    },
    destroyed() {
      this.editor.destroy();
    }
  }
</script>

引入方式:

<UE :defaultMsg=defaultMsg :config=config :id=ue1 ref="ue"></UE>

data() {
    return {
      defaultMsg: "",
      image: "",
      config: {
        initialFrameWidth: null,
        initialFrameHeight: 350
      },
      ue1: "ue1"
    };
  },

就可以成功配置好ueditor的基本功能了

 

三、前后台请求代理

在vue dev环境下可以设置webpack的proxyTable将后端请求代理转发,就可以轻松调试文件上传功能了,同理,vue build之后的文件则需要用Node将静态文件代理到和后端同一个端口上才可以请求后台端口

 

篇幅有限,文章可能讲述的不太清晰,具体的可以看我这个项目的代码:https://github.com/cheer4chai/myBlog



nodejs+mongodb+vue前后台配置ueditor

标签:mongod   resolve   data   alt   install   有关   blog   cti   安装   

人气教程排行