//输入框表单验证 inputReg(){ //获取输入框的内容 var val = this.cardNum; //将所有的非数字替换为空 然后每四位加一个空格 val = val.replace(/[^d]/g,'').replace(/(d{4})(?=d)/g,'$1 '); this.cardNum = val; //卡号为16为 加3个空格 if(val.length >= 19){ this.cardNum = val.substr(0, 19) //红色按钮 this.isActive = true }else{ //灰色按钮 this.isActive = false; } },