V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
luminousNcc
V2EX  ?  Vue.js

如何优化 Element UI 2.0 的 input 组件在巨量文本下拖动和输入的卡顿问题?

  •  
  •   luminousNcc · 26 天前 · 877 次点击

    腾讯云最新优惠活动来了:云产品限时1折,云服务器低至88元/年 ,点击这里立即抢购:9i0i.cn/qcloud,更有2860元代金券免费领取,付款直接抵现金用,点击这里立即领取:9i0i.cn/qcloudquan

    (福利推荐:你还在原价购买阿里云服务器?现在阿里云0.8折限时抢购活动来啦!4核8G企业云服务器仅2998元/3年,立即抢购>>>:9i0i.cn/aliyun

    各位大佬,小弟最近接手了一个项目,是一个 TXT 文档的在线编辑器,使用基于 Vue2 的 Element UI 2.0.

    编辑器的部分直接用了一个el-input,具体如下所示:

    <el-input
      v-model="book.content"
      type="textarea"
      :autosize="{ minRows: 10, maxRows: 30 }"/>
    

    现在的问题是当这个 TXT 文档的内容量过大(字数超过 100000 后):

    1. 拖动右侧的滚动条,文本渲染卡顿,拖动一次到内容呈现需要 2-3 秒。
    2. 输入文字时卡顿,从键盘敲击到文字出现需要 5 秒。
    3. 点击插入光标时卡顿,从点击到光标响应出现需要 2-3 秒。

    想请问各位大佬有什么优化这种卡顿问题的方法吗?

    5 条回复  ?  2024-04-13 06:51:30 +08:00
    asiasky
        1
    asiasky  
       25 天前   ?? 1
    用元素的 contnetEditable 属性做输入,https://caniuse.com/?search=contentEditable
    ZGame
        2
    ZGame  
       25 天前
    换成 vscode ide 的编辑器内核
    realJamespond
        3
    realJamespond  
       25 天前
    换第三方的 editor 试试,ckeditor
    Kmmoonlight
        4
    Kmmoonlight  
       25 天前
    https://prosemirror.net/examples/ ProseMirror 我们内网项目写脚本用这个
    luminousNcc
        5
    luminousNcc  
    OP
       23 天前
    @Kmmoonlight 感谢大佬,帮大忙了!这个性能确实快
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1083 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 18:53 · PVG 02:53 · LAX 11:53 · JFK 14:53
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com