第一种:
html
maxlength为限制输入框输入的最长长度,因为我这里对input做了一些空格加入,所以变成13,要是你们不做分隔,写11就行
<input type="text" id="name" maxlength="13" placeholder="请输入手机号码" (keyup)='onPhoneup($event)' (keypress)='onPhonepress($event)' />
ts:
export class XXX {
public phoneNumber: any =</