分享

vue加载百度Ueditor编辑器

 看见就非常 2020-05-08

下载代码:http://ueditor.baidu.com/website/download.html

在HTML文件的head引入以下文件:

  1. <!-- 编辑器依赖 begin -->
  2. <script src="./ueditor/ueditor.config.js"></script>
  3. <script src="./ueditor/ueditor.all.min.js"></script>
  4. <script src="./ueditor/lang/zh-cn/zh-cn.js"></script>
  5. <link rel="stylesheet" href="./ueditor/themes/default/css/ueditor.css'">
  6. <!-- 编辑器依赖 end -->

注意:引入路径根据文件的实际存放路径来写就好

接下来在组件里就可以用了,组件完整代码:

  1. <template>
  2. <div>
  3. <div id="container" style="width:50vw; height:300px;"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. name: 'index',
  9. data() {
  10. return {
  11. editor: null,
  12. value: ''
  13. }
  14. },
  15. mounted() {
  16. this.editor = window.UE.getEditor('container')
  17. this.editor.addListener('ready', () => {
  18. this.editor.setContent(this.value)
  19. })
  20. }
  21. }
  22. </script>
  23. <style>
  24. </style>

这样就可以了,菜单可以根据需要,自己在ueditor.config.js文件中配置。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多