search.js 947 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. let count = null;
  2. Component({
  3. properties: {
  4. inputSharch: {
  5. type: Function
  6. },
  7. selectSort: {
  8. type: Function
  9. },
  10. isReverse: Boolean
  11. },
  12. data: {
  13. isClear: false
  14. },
  15. options: {
  16. addGlobalClass: true,
  17. },
  18. methods: {
  19. textChange(e) {
  20. clearTimeout(count);
  21. if (this.data.isClear) {
  22. this.triggerEvent("inputSharch");
  23. this.setData({
  24. isClear: false
  25. })
  26. return;
  27. }
  28. e.type == "change" ? count = setTimeout(() => this.triggerEvent("inputSharch", e.detail.trim()), 1000) : this.triggerEvent("inputSharch", e.detail.trim());
  29. },
  30. onClear() {
  31. this.setData({
  32. isClear: true
  33. })
  34. },
  35. handleSort() {
  36. this.triggerEvent("selectSort")
  37. },
  38. }
  39. })