clickoutside.ts 704 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * @Author: weisheng
  3. * @Date: 2023-07-02 22:51:06
  4. * @LastEditTime: 2024-03-16 19:59:07
  5. * @LastEditors: weisheng
  6. * @Description:
  7. * @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/common/clickoutside.ts
  8. * 记得注释
  9. */
  10. let queue: any[] = []
  11. export function pushToQueue(comp: any) {
  12. queue.push(comp)
  13. }
  14. export function removeFromQueue(comp: any) {
  15. queue = queue.filter((item) => {
  16. return item.$.uid !== comp.$.uid
  17. })
  18. }
  19. export function closeOther(comp: any) {
  20. queue.forEach((item) => {
  21. if (item.$.uid !== comp.$.uid) {
  22. item.$.exposed.close()
  23. }
  24. })
  25. }
  26. export function closeOutside() {
  27. queue.forEach((item) => {
  28. item.$.exposed.close()
  29. })
  30. }