plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.8 KiB

3 years ago
  1. <template>
  2. <div class="mod-demo-ueditor">
  3. <el-alert
  4. title="提示:"
  5. type="warning"
  6. :closable="false">
  7. <div slot-scope="description">
  8. <p class="el-alert__description">1. 此Demo只提供UEditor官方使用文档入门部署和体验功能具体使用请参考http://fex.baidu.com/ueditor/</p>
  9. <p class="el-alert__description">2. 浏览器控制台报错请求后台配置项http错误上传功能将不能正常使用此错需要后台提供上传接口方法赋值给serverUrl属性</p>
  10. </div>
  11. </el-alert>
  12. <script :id="ueId" class="ueditor-box" type="text/plain" style="width: 100%; height: 260px;">hello world!</script>
  13. <!-- 获取内容 -->
  14. <p><el-button @click="getContent()">获得内容</el-button></p>
  15. <el-dialog
  16. title="内容"
  17. :visible.sync="dialogVisible"
  18. :append-to-body="true">
  19. {{ ueContent }}
  20. <span slot="footer" class="dialog-footer">
  21. <el-button type="primary" @click="dialogVisible = false"> </el-button>
  22. </span>
  23. </el-dialog>
  24. </div>
  25. </template>
  26. <script>
  27. import ueditor from 'ueditor'
  28. export default {
  29. data () {
  30. return {
  31. ue: null,
  32. ueId: `J_ueditorBox_${new Date().getTime()}`,
  33. ueContent: '',
  34. dialogVisible: false
  35. }
  36. },
  37. mounted () {
  38. this.ue = ueditor.getEditor(this.ueId, {
  39. // serverUrl: '', // 服务器统一请求接口路径
  40. zIndex: 3000
  41. })
  42. },
  43. methods: {
  44. getContent () {
  45. this.dialogVisible = true
  46. this.ue.ready(() => {
  47. this.ueContent = this.ue.getContent()
  48. })
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss">
  54. .mod-demo-ueditor {
  55. position: relative;
  56. z-index: 510;
  57. > .el-alert {
  58. margin-bottom: 10px;
  59. }
  60. }
  61. </style>