search.js 977 B

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