From 469c648c1486994e1e0b3b0083b25d76b3ed82b5 Mon Sep 17 00:00:00 2001 From: wangsongsole Date: Tue, 16 Jan 2024 14:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AA=20optimize:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/knockGold/wangEditor.jsx | 74 +++++++++---------- src/components/redPackets/wangEditor.jsx | 5 +- .../redPackets/zfb-mobileComponent.jsx | 2 +- 3 files changed, 39 insertions(+), 42 deletions(-) diff --git a/src/components/knockGold/wangEditor.jsx b/src/components/knockGold/wangEditor.jsx index 82bedc60..43fde914 100644 --- a/src/components/knockGold/wangEditor.jsx +++ b/src/components/knockGold/wangEditor.jsx @@ -1,65 +1,59 @@ -import React from 'react'; -import Editor from 'wangeditor'; -import './index.less'; +import React from "react" +import Editor from "wangeditor" +import "./index.less" export default class wangEditor extends React.Component { constructor(props) { - super(props); + super(props) this.state = { - editorHtml: '', + editorHtml: "", count: 0 - }; + } } componentDidMount() { - let self = this; - const editor = new Editor('#wangeditorDom'); - this.setState({ editor }); - editor.config.colors = ['#696969', '#9093a2', '#fgddbb', '#e3e7eb']; - editor.config.pasteText = true; + let self = this + const editor = new Editor("#wangeditorDom") + this.setState({ editor }) + editor.config.colors = ["#696969", "#9093a2", "#fgddbb", "#e3e7eb"] + editor.config.pasteText = true // 设置编辑区域高度为 500px - editor.config.height = 200; - editor.config.showFullScreen = false; - editor.config.menus = [ - 'bold', - 'foreColor', - 'italic', - 'indent', - 'link', - 'justify' - ]; + editor.config.height = 200 + editor.config.showFullScreen = false + editor.config.menus = ["bold", "foreColor", "italic", "indent", "link", "justify"] // 注意,先配置 height ,再执行 create() // 注意,先配置 height ,再执行 create() editor.config.onchange = function (newHtml) { - var text = editor.txt.text(); + var text = editor.txt.text() if (text.length == 0) { //没有文字 - self.props.setEdittext(''); + self.props.setEdittext("") } if (text.length > self.props.limitLength) { - let str = text.slice(0, self.props.limitLength); - self.setState({ editorHtml: str }); - editor.txt.html(str); - self.props.setEdittext(str); - return; + let str = text.slice(0, self.props.limitLength) + self.setState({ editorHtml: str }) + editor.txt.html(str) + self.props.setEdittext(str) + return } - self.setState({ count: text.length }); - self.setState({ editorHtml: newHtml }); - self.props.setEdittext(newHtml); - }; + self.setState({ count: text.length }) + self.setState({ editorHtml: newHtml }) + self.props.setEdittext(newHtml) + } - editor.create(); + editor.create() //列表悬浮富文本 - editor.txt.html(this.props.text); + const clr = setTimeout(() => { + editor.txt.html(this.props.text) + clearTimeout(clr) + }, 500) } render() { return ( -
-
-

- {this.state.count + '/' + this.props.limitLength} -

+
+
+

{this.state.count + "/" + this.props.limitLength}

- ); + ) } } diff --git a/src/components/redPackets/wangEditor.jsx b/src/components/redPackets/wangEditor.jsx index 39ed94dd..43fde914 100644 --- a/src/components/redPackets/wangEditor.jsx +++ b/src/components/redPackets/wangEditor.jsx @@ -42,7 +42,10 @@ export default class wangEditor extends React.Component { editor.create() //列表悬浮富文本 - editor.txt.html(this.props.text) + const clr = setTimeout(() => { + editor.txt.html(this.props.text) + clearTimeout(clr) + }, 500) } render() { diff --git a/src/components/redPackets/zfb-mobileComponent.jsx b/src/components/redPackets/zfb-mobileComponent.jsx index 5820462b..812cf99f 100644 --- a/src/components/redPackets/zfb-mobileComponent.jsx +++ b/src/components/redPackets/zfb-mobileComponent.jsx @@ -56,7 +56,7 @@ export default ({ data }) => {

您可在支付宝的个人信息中查看【支付宝账号】