From 3e1db1b125df36d6fe5c5b944e2e71a43c3313a9 Mon Sep 17 00:00:00 2001 From: binbin_pan Date: Mon, 22 Apr 2024 12:04:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E8=BE=93=E5=85=A5=E5=AD=97?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgzb-ui/src/views/system/notice/index.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sgzb-ui/src/views/system/notice/index.vue b/sgzb-ui/src/views/system/notice/index.vue index ca22b40a..9ecfa742 100644 --- a/sgzb-ui/src/views/system/notice/index.vue +++ b/sgzb-ui/src/views/system/notice/index.vue @@ -261,7 +261,7 @@ v-model="form.noticeContent" :min-height="192" :max-length="200" - :placeholder="'请输入内容'" + @input="handleEditorChange" /> @@ -433,6 +433,20 @@ }) .catch(() => {}) }, + handleEditorChange(value) { + let parser = new DOMParser() + let doc = parser.parseFromString(value, "text/html") + let text = doc.body.textContent || "" + // 当text.length 超过200 时候,提示用户并且截取前200个字符 + if (text.length > 200) { + this.$message({ + message: '公告内容不能超过200个字符!', + type: 'warning' + }) + this.form.noticeContent = text.substring(0, 200) + return + } + }, }, }