1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| <template> <div id="wangeditor"> <div ref="editorElem" style="text-align:left"></div> </div> </template> <script> import E from 'wangeditor' export default { name: 'editorElem', data () { return { editorContent: '', } }, props:['catchData'], mounted() { var editor = new E(this.$refs.editorElem) editor.customConfig.onchange = (html) => { this.editorContent = html this.catchData(html) } editor.customConfig.uploadImgServer = '你的上传图片的接口' editor.customConfig.uploadFileName = '你自定义的文件名' editor.customConfig.uploadImgHeaders = { 'Accept': '*/*', 'Authorization':'Bearer ' + token } editor.customConfig.menus = [ 'head', 'bold', 'fontSize', 'fontName', 'italic', 'underline', 'strikeThrough', 'foreColor', 'backColor', 'link', 'list', 'justify', 'quote', 'emoticon', 'image', 'table', 'video', 'code', 'undo', 'redo' ] editor.customConfig.uploadImgHooks = { before: function (xhr, editor, files) { }, success: function (xhr, editor, result) { this.imgUrl=Object.values(result.data).toString() }, fail: function (xhr, editor, result) { }, error: function (xhr, editor) { }, timeout: function (xhr, editor) { }, customInsert: function (insertImg, result, editor) { let url = Object.values(result.data) JSON.stringify(url) insertImg(url) } } editor.create() } } </script>
|