index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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: '#ffffff'
  18. },
  19. maxlength: {
  20. type: Number,
  21. value: -1
  22. },
  23. shape: {
  24. type: String,
  25. value: 'square'
  26. },
  27. label: String
  28. },
  29. methods: {
  30. onChange(event) {
  31. this.set({ value: event.detail });
  32. this.$emit('change', event.detail);
  33. },
  34. onCancel() {
  35. this.set({ value: '' });
  36. this.$emit('cancel');
  37. this.$emit('change', '');
  38. },
  39. onSearch() {
  40. this.$emit('search', this.data.value);
  41. },
  42. onFocus() {
  43. this.$emit('focus');
  44. },
  45. onBlur() {
  46. this.$emit('blur');
  47. },
  48. onClear() {
  49. this.$emit('clear');
  50. },
  51. }
  52. });