【发布时间】:2021-08-20 23:40:39
【问题描述】:
您好,我正在实现 OTP 功能模式,该模式可以打开几次,一次是在您导航到应用程序时,然后是一些特定操作,例如单击某个操作按钮。
如果这很重要,我正在使用 Vue2 和 Buefy,所以问题是,一旦我提交代码并再次打开模式,它之前已经添加了填充的代码。我尝试将自动完成指定为one-time-code 或new-password,它们都不起作用。
这是我的实现
输入组件
<b-input
:name="name"
:value="value"
:placeholder="placeholder"
:disabled="disabled"
:maxlength="maxLength"
:type="type"
:autocomplete="autocomplete"
:inputmode="inputmode"
@input="(value) => $emit('input', value)"
>
</b-input>
JS部分
export default {
name: "Input",
props: {
name: String,
label: String,
placeholder: String,
value: String,
autocomplete: String,
inputmode: {
type: String,
default: "text"
},
type: {
type: String,
default: "text"
},
disabled: {
type: Boolean,
default: false
},
maxLength: Number
}
};
OTP 模式
<b-modal :active="isOpen" width="200" :can-cancel="canCancel">
<div>
<h2>Otp modal</h2>
<Input
label="Otp code"
name="otp"
v-model="code"
placeholder="code"
type="password"
:maxLength="4"
autocomplete="one-time-code"
inputMode="numeric"
/>
<slot></slot>
<b-button type="is-primary" @click="close">Submit</b-button>
<b-button type="is-primary is-light" @click="close">Close</b-button>
</div>
</b-modal>
可点击演示的 CodeSandbox:https://codesandbox.io/s/buefy-otp-test-onuh1
【问题讨论】:
标签: javascript input vuejs2 one-time-password