index.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. clearTrigger: {
  47. type: String,
  48. value: 'focus',
  49. },
  50. clearIcon: {
  51. type: String,
  52. value: 'clear',
  53. },
  54. },
  55. methods: {
  56. onChange: function (event) {
  57. if (version_1.canIUseModel()) {
  58. this.setData({ value: event.detail });
  59. }
  60. this.$emit('change', event.detail);
  61. },
  62. onCancel: function () {
  63. var _this = this;
  64. /**
  65. * 修复修改输入框值时,输入框失焦和赋值同时触发,赋值失效
  66. * https://github.com/youzan/@vant/weapp/issues/1768
  67. */
  68. setTimeout(function () {
  69. if (version_1.canIUseModel()) {
  70. _this.setData({ value: '' });
  71. }
  72. _this.$emit('cancel');
  73. _this.$emit('change', '');
  74. }, 200);
  75. },
  76. onSearch: function (event) {
  77. this.$emit('search', event.detail);
  78. },
  79. onFocus: function (event) {
  80. this.$emit('focus', event.detail);
  81. },
  82. onBlur: function (event) {
  83. this.$emit('blur', event.detail);
  84. },
  85. onClear: function (event) {
  86. this.$emit('clear', event.detail);
  87. },
  88. onClickInput: function (event) {
  89. this.$emit('click-input', event.detail);
  90. },
  91. },
  92. });