index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { VantComponent } from '../common/component';
  2. VantComponent({
  3. field: true,
  4. classes: ['field-class', 'input-class', 'cancel-class'],
  5. props: {
  6. focus: Boolean,
  7. error: Boolean,
  8. disabled: Boolean,
  9. readonly: Boolean,
  10. inputAlign: String,
  11. showAction: Boolean,
  12. useActionSlot: Boolean,
  13. placeholder: String,
  14. placeholderStyle: String,
  15. background: {
  16. type: String,
  17. value: '#f2f2f2'
  18. },
  19. maxlength: {
  20. type: Number,
  21. value: -1
  22. }
  23. },
  24. methods: {
  25. onChange: function onChange(event) {
  26. this.set({
  27. value: event.detail
  28. });
  29. this.$emit('change', event.detail);
  30. },
  31. onCancel: function onCancel() {
  32. this.set({
  33. value: ''
  34. });
  35. this.$emit('cancel');
  36. this.$emit('change', '');
  37. },
  38. onSearch: function onSearch() {
  39. this.$emit('search', this.data.value);
  40. },
  41. onFocus: function onFocus() {
  42. this.$emit('focus');
  43. },
  44. onBlur: function onBlur() {
  45. this.$emit('blur');
  46. },
  47. onClear: function onClear() {
  48. this.$emit('clear');
  49. }
  50. }
  51. });