From a6fff7f7a3224b6207ad9c832af79c0d70f175fe Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Fri, 21 Apr 2023 09:37:49 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=96=87=E5=AD=97=E6=95=B0=E9=87=8F=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Count.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/src/pages/Edit/components/Count.vue b/web/src/pages/Edit/components/Count.vue index b7fb3755..26bdf34a 100644 --- a/web/src/pages/Edit/components/Count.vue +++ b/web/src/pages/Edit/components/Count.vue @@ -17,11 +17,14 @@ * @Date: 2021-06-24 22:53:10 * @Desc: 字数及节点数量统计 */ + +let countEl = document.createElement('div') export default { name: 'Count', props: {}, data() { return { + textStr: '', words: 0, num: 0 } @@ -39,9 +42,12 @@ export default { * @Desc: 监听数据变化 */ onDataChange(data) { + this.textStr = '' this.words = 0 this.num = 0 this.walk(data) + countEl.innerHTML = this.textStr + this.words = countEl.textContent.length }, /** @@ -51,7 +57,7 @@ export default { */ walk(data) { this.num++ - this.words += (String(data.data.text) || '').length + this.textStr += String(data.data.text) || '' if (data.children && data.children.length > 0) { data.children.forEach(item => { this.walk(item)