index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <view class="en-box">
  3. <input class="en-input sys-size-32 text-color-12 sys-weight-600"
  4. placeholder-class="sys-size-28 text-color-999 sys-weight-400" :maxlength="maxlength" :type="type"
  5. :focus="focus" :placeholder="placeholder ? placeholder : ''" :disabled="!!disabled" v-model="inputValue"
  6. @blur="nameInput" @input="nameInput"></input>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'en-input',
  12. props: {
  13. type: {
  14. type: String,
  15. default: 'text'
  16. },
  17. placeholder: {
  18. type: String,
  19. default: '请输入'
  20. },
  21. disabled: {
  22. default: false
  23. },
  24. name: {
  25. type: String,
  26. default: 'text'
  27. },
  28. value: {
  29. default: ''
  30. },
  31. maxlength: {
  32. default: 140
  33. },
  34. focus: {
  35. default: false
  36. }
  37. },
  38. data() {
  39. return {
  40. inputValue: '',
  41. showShake: false
  42. };
  43. },
  44. watch: {
  45. 'value': function() {
  46. if (this.inputValue !== this.value) {
  47. this.inputValue = this.value
  48. }
  49. },
  50. 'inputValue': function() {
  51. this.$emit('input', this.inputValue)
  52. }
  53. },
  54. mounted() {
  55. this.inputValue = this.value
  56. },
  57. methods: {
  58. nameInput(e) {
  59. if (this.type === 'nickname') {
  60. this.inputValue = e.detail.value
  61. }
  62. },
  63. }
  64. }
  65. </script>
  66. <style lang="scss">
  67. .en-input {
  68. .en-input {
  69. width: 100%;
  70. }
  71. .en-input-placeholder {
  72. color: #999999;
  73. font-size: 28rpx;
  74. }
  75. }
  76. </style>