PEax

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

  •  
  •   PEax · Mar 17, 2022 · 1194 views
    This topic created in 1528 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   ·   2705 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 15:25 · PVG 23:25 · LAX 08:25 · JFK 11:25
    ♥ Do have faith in what you're doing.