compatible.js 909 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * 做兼容相关的函数集文件
  3. */
  4. /**
  5. * 阻止事件冒泡
  6. */
  7. export const _stopPropagation = (e) => {
  8. // window.event ? window.event.cancelBubble = true : e.stopPropagation();
  9. if(window&&window.event){
  10. window.event.cancelBubble = true
  11. }else{
  12. e.stopPropagation();
  13. }
  14. }
  15. /*
  16. 在需要回退刷新的页面配置ifFromChildPage
  17. */
  18. export const _goBackFresh = (pathName)=>{
  19. const pages = getCurrentPages();
  20. const reversed = pages.reverse();
  21. const currentPageIndex = 0;
  22. // console.log({reversed});
  23. if(true){
  24. pages.some((item,index)=>{
  25. // console.log('循环');
  26. if(item.route == pathName){
  27. let needdelta =index-currentPageIndex;
  28. // console.log({needdelta,index,currentPageIndex});
  29. //通知返回目标页面刷新数据
  30. item.ifFromChildPage=true;
  31. uni.navigateBack({
  32. delta: needdelta
  33. });
  34. return true;
  35. }
  36. });
  37. }
  38. }