【发布时间】:2021-10-18 14:10:44
【问题描述】:
我在示例 https://www.npmjs.com/package/ngx-otp-input#otpchange 中尝试使用 ionic 5 的 ngx-otp-input,但 autofocus 对我不起作用。 有什么想法吗?
【问题讨论】:
我在示例 https://www.npmjs.com/package/ngx-otp-input#otpchange 中尝试使用 ionic 5 的 ngx-otp-input,但 autofocus 对我不起作用。 有什么想法吗?
【问题讨论】:
Add in HTML
<ngx-otp-input [config]="otpInputConfig" (otpChange)="handeOtpChange($event)" (fill)="handleFillEvent($event)">
</ngx-otp-input>
Add in TS File
otpInputConfig: NgxOtpInputConfig = {
otpLength: 6,
autofocus: true,
classList: {
inputBox: "my-super-box-class",
input: "my-super-class",
inputFilled: "my-super-filled-class",
inputDisabled: "my-super-disable-class",
inputSuccess: "my-super-success-class",
inputError: "my-super-error-class"
}
};
handeOtpChange(value: string[]): void {
console.log(value);
}
handleFillEvent(value: string): void {
console.log(value);
}
【讨论】: