1如图 取20相加 左侧是含0的右侧为自动生成的数
2在watch监听里处理代码
'unclassed.docIdentity1':function (val, oldVal) {
// 将数字转成数组便于遍历
// let str = val.replace(/(?=(\B)(\d{1})+$)/g, ',')
let str = val.replace(/(?=(\B)(\d{0})+$)/g, ',')
let arr = [...str]
// 如果一直输入用于清除存在的
this.numBe=''
this.zero=''
arr.forEach((v,i)=>{
// 0 改成变量 方便后面为0时进下面的数据
if(v!=='0'){
// 不为0时打开累计
this.showNabo=true
if(i===0){
this.uuuu=String('')
}
}else {
// 用于删除后看第一个为0则不走累加
if(Number(v)===Number(i)){
this.showNabo=false
}
// 当不为true也只能是最前面输入的0 后面在输入的会忽略
if(this.showNabo==false){
this.zero=this.zero+v
this.uuuu=this.zero
}
}
// 当进入循环赋值为true进入
if(this.showNabo){
this.numBe= this.numBe+v
let matwe=JSON.parse(JSON.stringify(this.numBe))
this.unclassed.docIdentity2=this.uuuu +( Number(this.unclassed.docIdentity)+Number(matwe))
}
})
},