index.js 2.6 KB

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