<inputv-model="phone"placeholder="请输入手机号码"type="text"ref="cardInput"maxlength="13"@input="formatCardNumber"id="bankAccountNo"/>formatCardNumber(){let that = this let elem = document.getElementById('bankAccountNo');let patten = /\D/glet curpos = elem.selectionStart;let old_value = elem.value; that.phone = this.paddingSpace(elem.value.replace(patten, ""));if (old_value[curpos - 1] == " ") {curpos += -1;} else {var old_cursor = old_value.slice(0, curpos);var old_cursor_spaced = this.paddingSpace(old_cursor.replace(patten, ""));curpos += old_cursor_spaced.length - old_cursor.length;}setTimeout(function () {elem.focus();elem.setSelectionRange(curpos, curpos);}, 0);},paddingSpace(str) {return str.replace(/\s/,'').replace(/(\d{4})(?=\d)/g,"$1 ");},