当前位置: 首页 > news >正文

监控Vue输入框输入内容后,将换行、空格、空白符、回车和制表符转逗号

1、输入框

<input  v-model="inputValue" ></input>

<span v-show="false">{{resultString}}</span>

2、数据参数

data(){

return {

inputValue:''

}

}

3、变更数据

computed: {

    resultString () {

      const reg = /[\n\r\t\s]+/g // 注意:我添加了+来确保至少替换一个连续的空白字符

      console.log('resultString', this.inputValue)

      console.log('resultString', this.inputValue.replace(reg, ','))

      // eslint-disable-next-line vue/no-side-effects-in-computed-properties

      this.inputValue = this.inputValue.replace(reg, ',')

      return this.inputValue.replace(reg, ',')

    }

  },

4、应用场景

拷贝Excel或者其他需要多个同一属性的内容。


http://www.mrgr.cn/news/3037.html

相关文章:

  • 微信小程序实例代码解读
  • python中的randint如何使用
  • Java-RestTemplate中几种常用方法
  • 每日一问:Kafka消息丢失与堆积问题分析(简化版)
  • Python中的会话管理:requests.Session深度解析
  • 排序算法【归并排序】
  • 物联网架构之Hadoop
  • 3 nestjs 集成 Swagger
  • 魔珐科技出席WWEC教育者大会,给出AI时代教培行业精细化运营赋能方案
  • 什么是进程?C语言
  • Linux2.6设备驱动开发
  • Jmeter请求发送加密参数详解
  • Renumber程序——后面的想法没有实现
  • linux使用nginx部署springboot + vue分离项目
  • 【微信小程序】基础连接微信云数据库
  • 音视频相关知识
  • Nginx优化与防盗链
  • NoClassDefFoundError
  • 《区块链:能源市场变革的引领者》
  • 盒马鲜生源码开发