index.vue 1.4 KB

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