keyboard-input.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="tui-keyboard-input tui-pwd-box" :style="{background:bgcolor}">
  3. <view class="tui-inner-box">
  4. <view class="tui-input" :class="[inputvalue.length===4?'tui-margin-right':'']" :style="{fontSize:px(size),color:color,width:px(inputvalue.length===4?90:70)}"
  5. v-for="(item,index) in inputvalue" :key="index">{{item}}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name:"KeyboardInput",
  12. props: {
  13. //背景颜色
  14. bgcolor: {
  15. type: String,
  16. default: "#fff"
  17. },
  18. size: {
  19. type: Number,
  20. default: 32
  21. },
  22. color: {
  23. type: String,
  24. default: "#333"
  25. },
  26. //输入框的值:数组格式,长度即为输入框个数
  27. inputvalue: {
  28. type: Array,
  29. default: ["", "", "", "", "", ""] //密码圆点 ●
  30. }
  31. },
  32. data() {
  33. return {
  34. };
  35. },
  36. methods: {
  37. px(num) {
  38. return uni.upx2px(num) +"px"
  39. }
  40. }
  41. }
  42. </script>
  43. <style>
  44. .tui-pwd-box {
  45. display: flex;
  46. align-items: center;
  47. justify-content: center;
  48. box-sizing: border-box;
  49. vertical-align: top;
  50. }
  51. .tui-inner-box {
  52. display: flex;
  53. align-items: center;
  54. justify-content: center;
  55. }
  56. .tui-input {
  57. height: 80upx;
  58. position: relative;
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. margin-right: 20upx;
  63. border-bottom: 2px solid #666;
  64. }
  65. .tui-margin-right {
  66. margin-right: 30upx;
  67. }
  68. .tui-input:last-child {
  69. margin-right: 0 !important;
  70. }
  71. </style>