index.js 1.9 KB

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