search.js 919 B

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