代码如下,帮我看看好吗,感激!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | < div class = "border-1 border-solid border-[var(--tags-view-border-color)] z-10" > <!-- 工具栏 --> < Toolbar :editor = "editorRef" :editorId = "editorId" class = "border-0 b-b-1 border-solid border-[var(--tags-view-border-color)]" /> <!-- 编辑器 --> < Editor :model-value = "formData.html" :defaultConfig = "editorConfig" :editorId = "editorId" /> </ div > |
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | const editorRef = shallowRef<IDomEditor>() const editorId = ref( 'wangeEditor-123456789' ) const editorConfig = reactive({ placeholder: '请输入内容...' , customAlert: (s: string, t: string) => { switch (t) { case 'success' : ElMessage.success(s) break case 'info' : ElMessage.info(s) break case 'warning' : ElMessage.warning(s) break case 'error' : ElMessage.error(s) break default : ElMessage.info(s) break } }, autoFocus: false , scroll: true , MENU_CONF: { [ 'uploadImage' ]: { server: import.meta.env.VITE_UPLOAD_URL, // 单个文件的最大体积限制,默认为 2M maxFileSize: 5 * 1024 * 1024, // 最多可上传几个文件,默认为 100 maxNumberOfFiles: 10, // 选择文件时的类型限制,默认为 ['image/*'] 。如不想限制,则设置为 [] allowedFileTypes: [ 'image/*' ], // 自定义增加 http header headers: { Accept: '*' , Authorization: 'Bearer ' + getAccessToken(), 'tenant-id' : getTenantId() }, // 超时时间,默认为 10 秒 timeout: 5 * 1000, // 5 秒 // form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image fieldName: 'file' , // 上传之前触发 onBeforeUpload(file: File) { // console.log(file) return file }, // 上传进度的回调函数 onProgress(progress: number) { // progress 是 0-100 的数字 console.log( 'progress' , progress) }, onSuccess(file: File, res: any) { console.log( 'onSuccess' , file, res) }, onFailed(file: File, res: any) { alert(res.message) console.log( 'onFailed' , file, res) }, onError(file: File, err: any, res: any) { alert(err.message) console.error( 'onError' , file, err, res) }, // 自定义插入图片 customInsert(res: any, insertFn: any) { insertFn(res.data, 'image' , res.data) } }, [ 'uploadVideo' ]: { server: import.meta.env.VITE_UPLOAD_URL, // 单个文件的最大体积限制,默认为 10M maxFileSize: 10 * 1024 * 1024, // 最多可上传几个文件,默认为 100 maxNumberOfFiles: 10, // 选择文件时的类型限制,默认为 ['video/*'] 。如不想限制,则设置为 [] allowedFileTypes: [ 'video/*' ], // 自定义增加 http header headers: { Accept: '*' , Authorization: 'Bearer ' + getAccessToken(), 'tenant-id' : getTenantId() }, // 超时时间,默认为 30 秒 timeout: 15 * 1000, // 15 秒 // form-data fieldName,后端接口参数名称,默认值wangeditor-uploaded-image fieldName: 'file' , // 上传之前触发 onBeforeUpload(file: File) { // console.log(file) return file }, // 上传进度的回调函数 onProgress(progress: number) { // progress 是 0-100 的数字 console.log( 'progress' , progress) }, onSuccess(file: File, res: any) { console.log( 'onSuccess' , file, res) }, onFailed(file: File, res: any) { alert(res.message) console.log( 'onFailed' , file, res) }, onError(file: File, err: any, res: any) { alert(err.message) console.error( 'onError' , file, err, res) }, // 自定义插入图片 customInsert(res: any, insertFn: any) { insertFn(res.data, 'mp4' , res.data) } } }, uploadImgShowBase64: true }) |
formData.html的值为:
1 2 3 4 | < div class = "TRS_Editor" > < p align = "justify" style = "text-align: center;" > < img src = "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png" style = "border-width: 0px;" alt = "" oldsrc = "W020241122702188156563.jpg" ></ p > < p >test</ p > </ div > |
谢谢,就我现在的代码量,看得出有问题吗?
我的版本是:
1 2 | "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.10", |