el-input 控制银行账号每4个数字用空格分割
<el-input v-model="PJJFform.cpBankZh" @input="cpBankZhFormat()"></el-input>methods:{cpBankZhFormat:function () {this.PJJFform.cpBankZh=this.PJJFform.cpBankZh.replace(/\s/g, '').r...
·
<el-input v-model="PJJFform.cpBankZh" @input="cpBankZhFormat()"></el-input>
methods:{
cpBankZhFormat:function () {
this.PJJFform.cpBankZh=this.PJJFform.cpBankZh.replace(/\s/g, '').replace(/[^\d]/g, '').replace(/(\d{4})(?=\d)/g, '$1 ')
}
}
效果图:
如果在后续接口传参数时,需要把空格去掉,就把对应字段进行如下处理:
this.PJJFform.cpBankZh=this.PJJFform.cpBankZh.trim().replace(/\s/g,"")
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)