At first, I thought that if I needed six verification code boxes, I should simply create six <input> elements.
However, after implementing it, I ran into various issues:
- The cursor didn’t smoothly jump to the next input box
- The keyboard would suddenly disappear
- The overall typing experience felt clunky and not smooth
The correct approach is actually to use only one real input field, and simulate multiple input boxes through styling (spacing, highlighting, etc.).
Visually it looks like six input boxes, but in reality there is only one <input> element handling the input.
Correct Solution
1 | <view class="w-80 h-100 rad-10 b-a-9 tc f-50" v-for="(item,index) in 6"> |
1 | data() { |
Complete Version
You can refer to the full implementation here:
https://blog.csdn.net/u011423258/article/details/106683068?spm=1001.2014.3001.5506