en-input.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view class="box">
  3. <view class="input-box">
  4. <view class="input-box-left">
  5. {{ label }}
  6. </view>
  7. <input
  8. :name="name"
  9. :type="type"
  10. :placeholder="placeholder ? placeholder : ''"
  11. :disabled="!!disabled"
  12. v-model="inputValue"
  13. />
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'en-input',
  20. props: {
  21. type: {
  22. type: String,
  23. default: 'text'
  24. },
  25. label: {
  26. type: String,
  27. default: '标题'
  28. },
  29. placeholder: {
  30. type: String,
  31. default: '请输入'
  32. },
  33. disabled: {
  34. default: false
  35. },
  36. name: {
  37. type: String,
  38. default: 'text'
  39. },
  40. value: {
  41. default: ''
  42. }
  43. },
  44. data() {
  45. return {
  46. inputValue: ''
  47. }
  48. },
  49. components: {},
  50. mounted() {
  51. this.inputValue = this.value
  52. },
  53. watch: {
  54. 'value': function () {
  55. if (this.inputValue !== this.value) {
  56. this.inputValue = this.value
  57. }
  58. },
  59. 'inputValue': function () {
  60. this.$emit('input', this.inputValue)
  61. }
  62. },
  63. methods: {}
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .box{
  68. background-color: #ffffff;
  69. border-bottom: 2rpx solid #F0F0F0;
  70. padding: 34rpx 0 32rpx 0;
  71. .input-box {
  72. display: flex;
  73. align-items: center;
  74. .input-box-left {
  75. width: 210rpx;
  76. font-size: 32rpx;
  77. color: #333333;
  78. }
  79. }
  80. }
  81. </style>