index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. });