PEax

textarea 规定最多每行输入 35 个字符*4 行,如何实现?

  •  
  •   PEax · Mar 17, 2022 · 1218 views
    This topic created in 1541 days ago, the information mentioned may be changed or developed.

    半成品,但是写死固定了每行 35 个字符才会换行,实际上小于 35 个字符也符合要求,如何完善

    export function formatTextArea(val,model) {
      const reg = new RegExp(`(.{${35}})`, 'g')
      const result = val.replace(/[\r\n]/g, '').replace(reg, '$1\n')
      const arr = result.split('\n').slice(0, 4)
      model.filed = arr.join('\n')
    }
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2803 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 05:34 · PVG 13:34 · LAX 22:34 · JFK 01:34
    ♥ Do have faith in what you're doing.