1.功能描述: 有四个input输入框,在一个input输入框中输满四个字符就自动聚焦到下一个input,复制粘贴类似于兑换码的 这种16位的ZPER-21UJ-PXPK-2Y13,粘贴后按照'-'切割自动分配到不同的input框中。
2.代码部分:
//HTML部分
<div class="box-flex"> <div class="p"> <input v-model="code_1" v-on:input="inputFunc(1)" type="text" style="background-color: transparent; border: 0" /> <span></span> <input v-model="code_2" v-on:input="inputFunc(2)" id="code_2" type="text" style="background-color: transparent; border: 0" /> <span></span> <input v-model="code_3" v-on:input="inputFunc(3)" id="code_3" type="text" style="background-color: transparent; border: 0" /> <span></span> <input v-model="code_4" v-on:input="inputFunc(4)" id="code_4" type="text" style="background-color: transparent; border: 0" /> </div> <p class="commit" @click="commit">兑换</p> </div>
//js部分