分类 技术相关 下的文章

核心点:

使用activated事件,被keep-alive 缓存的组件激活时调用
》在路由进入之前标记来源

beforeRouteEnter(to, from, next) {
  if (from.name == 'aaaa') { // 这个name是下一级页面的路由name
    to.meta.isBack = true; // 设置为true说明你是返回到这个页面
  }
  next();
},

activated() { 
  console.log('被keep-alive 缓存的组件激活时调用')
  if (this.$route.meta.isBack) { 
    console.log("页面回退执行刷新")
    this.reInit(); //执行重新请求方法
  }
  this.$route.meta.isBack = false
},

使用场景:

待审核列表,打开审核后,再次回到列表中,列表页面应该重新请求数据。

按多字段排序::

Comparator<VO> bya = Comparator.comparing(VO::getAppId).reversed();//按照a升序
Comparator<VO> byb = Comparator.comparing(VO::getNum).reversed();//按照b降序
Collections.sort(resultlist,bya.thenComparing(byb));

按单字段降序排序

Collections.sort(resultlist,(a, b)->b.getNum().compareTo(a.getNum()));

核心代码如下

      List picList = new ArrayList();
        try{
            String basepath= ServletContextFactory.getServletContext().getRealPath("/");
            String path="userfiles/pics";
            File toSaveFile=new File(basepath+path);
            Collection<File> listFiles = FileUtils.listFiles(toSaveFile,"jpg".split(","),false);
            if(listFiles!=null && listFiles.size()>0){
                for (File file : listFiles){
                 picList.add(file.getName());
                }
            }
            
        }catch (Exception e){
            logger.error("得到文件夹下的所有指定格式文件列表异常",e);
        }

代码解析

1.String basepath= ServletContextFactory.getServletContext().getRealPath("/");
获取项目根路径地址。

2.Collection<File> listFiles = FileUtils.listFiles(toSaveFile,"jpg".split(","),false);
列出指定目录jpg格式的所有文件。false,代表不扫描子目录

背景

pod install 相关类库,尤其update的时候 默认的github太慢了。部分博客指出的清华镜像现在也用不了了,后来发现官方的cdn的确比较好用。

pod 镜像 cdn

使用步骤

1.podfile添加cdn source删除原来的github Spec

前提是pod版本1.8+,查看pod 版本,pod --version

2.大胆删除原来的CocoaPods 分支

pod repo remove master
或手动删除,目录是在 /用户/XXX/.cocoapods/repos/,此目录超级大,删除cocoapods目录即可。

3.执行pod install

pod install 可以看出从cdn安装类库。如果是新项目使用,需要pod setup再使用

更多详情参见

https://blog.cocoapods.org/CocoaPods-1.8.0-beta/
https://my.oschina.net/u/1993252/blog/3110883

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系[email protected]。我们会在24小时内进行删除。