Ueditor.vue 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <div>
  3. <script id="editor" type="text/plain" ></script>
  4. </div>
  5. </template>
  6. <script>
  7. import '@/assets/static/ueditor/ueditor.config.js'
  8. import '@/assets/static/ueditor/ueditor.all.js'
  9. import '@/assets/static/ueditor/lang/zh-cn/zh-cn.js'
  10. export default {
  11. name: 'UEditor',
  12. props: {
  13. id: {
  14. type: String
  15. },
  16. config: {
  17. type: Object
  18. }
  19. },
  20. data () {
  21. return {
  22. editor: null
  23. }
  24. },
  25. mounted () {
  26. // 初始化UE
  27. const _this = this
  28. this.editor = UE.delEditor('editor')
  29. this.editor = UE.getEditor('editor', this.config)
  30. },
  31. destoryed () {
  32. this.editor.destory()
  33. },
  34. methods: {
  35. getUEContent: function () {
  36. return this.editor.getContent()
  37. },
  38. setContent: function (content) {
  39. const ue = UE.getEditor('editor')
  40. ue.ready(function () {
  41. ue.setContent(content)
  42. })
  43. },
  44. getContentTxt: function () {
  45. return this.editor.getContentTxt()
  46. }
  47. }
  48. }
  49. </script>