电话号码空格
监听input的keyup和keydown事件
mobileKeyUp (key) {
if ((this.familyInfo.contact_no.length === 3 || this.familyInfo.contact_no.length === 8) && key.keyCode !== 8) {
this.familyInfo.contact_no = this.familyInfo.contact_no + ' '
} else if ((this.familyInfo.contact_no.length === 4 || this.familyInfo.contact_no.length === 9) && key.keyCode === 8) {
this.familyInfo.contact_no = this.familyInfo.contact_no.substr(0, this.familyInfo.contact_no.length - 1)
}
if (this.shouldAddSpace) {
let lastNewStr = this.familyInfo.contact_no.charAt(this.familyInfo.contact_no.length - 1)
this.familyInfo.contact_no = this.familyInfo.contact_no.substr(0, this.familyInfo.contact_no.length - 1)
this.familyInfo.contact_no = this.familyInfo.contact_no + ' ' + lastNewStr
this.shouldAddSpace = false
}
},
mobileKeyDown (key) {
if ((this.familyInfo.contact_no.length === 3 || this.familyInfo.contact_no.length === 8) && key.keyCode !== 8) {
this.shouldAddSpace = true
}
}