index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. useLeftIconSlot: Boolean,
  17. useRightIconSlot: Boolean,
  18. leftIcon: {
  19. type: String,
  20. value: 'search'
  21. },
  22. rightIcon: String,
  23. placeholder: String,
  24. placeholderStyle: String,
  25. actionText: {
  26. type: String,
  27. value: '取消'
  28. },
  29. background: {
  30. type: String,
  31. value: '#ffffff'
  32. },
  33. maxlength: {
  34. type: Number,
  35. value: -1
  36. },
  37. shape: {
  38. type: String,
  39. value: 'square'
  40. },
  41. clearable: {
  42. type: Boolean,
  43. value: true
  44. }
  45. },
  46. methods: {
  47. onChange: function (event) {
  48. this.setData({ value: event.detail });
  49. this.$emit('change', event.detail);
  50. },
  51. onCancel: function () {
  52. var _this = this;
  53. /**
  54. * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效
  55. * https://github.com/youzan/@vant/weapp/issues/1768
  56. */
  57. setTimeout(function () {
  58. _this.setData({ value: '' });
  59. _this.$emit('cancel');
  60. _this.$emit('change', '');
  61. }, 200);
  62. },
  63. onSearch: function () {
  64. this.$emit('search', this.data.value);
  65. },
  66. onFocus: function () {
  67. this.$emit('focus');
  68. },
  69. onBlur: function () {
  70. this.$emit('blur');
  71. },
  72. onClear: function () {
  73. this.$emit('clear');
  74. },
  75. }
  76. });