compatible.js 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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,bool)=>{
  19. const pages = getCurrentPages();
  20. const reversed = pages.reverse();
  21. const currentPageIndex = 0;
  22. console.log({reversed,pages});
  23. if(true){
  24. pages.some((item,index)=>{
  25. // console.log('循环');
  26. // console.log({item});
  27. if(item.route == pathName){
  28. let needdelta =index-currentPageIndex;
  29. // console.log({needdelta,index,currentPageIndex});
  30. //通知返回目标页面刷新数据
  31. item.ifFromChildPage=true;
  32. uni.navigateBack({
  33. delta: needdelta
  34. });
  35. return true;
  36. }
  37. });
  38. }
  39. }