index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. component_1.VantComponent({
  5. field: true,
  6. classes: ['field-class', 'input-class', 'cancel-class'],
  7. props: {
  8. label: String,
  9. focus: Boolean,
  10. error: Boolean,
  11. disabled: Boolean,
  12. readonly: Boolean,
  13. inputAlign: String,
  14. showAction: Boolean,
  15. useActionSlot: Boolean,
  16. placeholder: String,
  17. placeholderStyle: String,
  18. background: {
  19. type: String,
  20. value: '#ffffff'
  21. },
  22. maxlength: {
  23. type: Number,
  24. value: -1
  25. },
  26. shape: {
  27. type: String,
  28. value: 'square'
  29. },
  30. clearable: {
  31. type: Boolean,
  32. value: true
  33. }
  34. },
  35. methods: {
  36. onChange: function (event) {
  37. this.set({ value: event.detail });
  38. this.$emit('change', event.detail);
  39. },
  40. onCancel: function () {
  41. var _this = this;
  42. /**
  43. * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效
  44. * // https://github.com/youzan/vant-weapp/issues/1768
  45. */
  46. setTimeout(function () {
  47. _this.set({ value: '' });
  48. _this.$emit('cancel');
  49. _this.$emit('change', '');
  50. }, 200);
  51. },
  52. onSearch: function () {
  53. this.$emit('search', this.data.value);
  54. },
  55. onFocus: function () {
  56. this.$emit('focus');
  57. },
  58. onBlur: function () {
  59. this.$emit('blur');
  60. },
  61. onClear: function () {
  62. this.$emit('clear');
  63. },
  64. }
  65. });