首页 > 其他分享 >前端APP版本号对比判断是否需要更新

前端APP版本号对比判断是否需要更新

时间:2023-02-13 17:47:20浏览次数:41  
标签:return 版本号 APP v2 v1 length let 前端

function compareVersion(newVersion, currentVersion) {
                const v1 = newVersion.split('.');
                const v2 = currentVersion.split('.');
                for (let i = 0; i < v1.length || i < v2.length; i++) {
                    let x = 0, y = 0;
                    if (i < v1.length) {
                        x = parseInt(v1[i]);
                    }
                    if (i < v2.length) {
                        y = parseInt(v2[i])
                    }
                    if (x > y) return 1;
                    if (x < y) return -1;
                }
                return 0;
            }
            let v1 = '3.34.001', v2 = '3.34.010';
            console.log(compareVersion(v1, v2));

 

标签:return,版本号,APP,v2,v1,length,let,前端
From: https://www.cnblogs.com/aishangliming/p/17117158.html

相关文章

  • ios打开第三方地图app
    https://www.jianshu.com/p/691dd39cb28c 【ios调起地图app】分三步:1、配置相对于地图app的LSApplicationQueriesSchemes白名单百度地图:baidumap高德地图:iosamap......
  • 前端面试题:如何实现事件总线 Event Bus
    前端面试题:如何实现事件总线EventBus介绍通常作为多个模块间的通信机制,相当于一个事件管理中心,一个模块发送消息,其它模块接受消息,就达到了通信的作用。原理本质上是......
  • springboot 读取配置 application.yml
    添加配配置信息spring:application:name:dataExChangePlatformdevtools:restart:enabled:trueadditional-paths:src/main/javae......
  • MobPush 助力工具 APP 激活用户,留存率提升 31%
    近几年里,吸引用户注意力的争夺在内容资讯行业十分激烈。在此背景下,能吸引用户注意力,能够高效连接内容与用户的APP将发挥出更大的增长潜力。近期,某工具APP与MobTech携......
  • uniapp 小程序引流关注公众号
    official-account组件说明:微信公众号关注组件。当用户扫小程序码打开小程序时,开发者可在小程序内配置公众号关注组件,方便用户快捷关注公众号,可嵌套在原生组件内。仅微信......
  • uni-app:使用uni-list显示列表数据之一(hbuilderx 3.6.18)
    一,演示代码:说明:演示代码中实现的功能:    1,各个列表项展示不同类型的内容    2,取消uni-list-item默认样式中的padding    3,  取消uni-list......
  • printThis前端打印插件
    文章目录​​一、前言:​​​​1、特征​​​​2、插件下载地址:​​​​二、用法:​​​​1、所有配置:​​​​三、示例代码:​​​​1、jsp代码:​​​​2、js部分:​​​​3......
  • [Error] a template declaration cannot appear at block scope
    测试C++11中  AliasTemplate时出现出现报错程序:#include<iostream>#include<vector>usingnamespacestd;intmain(){ template<typenameT> usingVec......
  • APP性能测试
    adb命令查看手机使用情况adbshelldumpsys[options]options:meminfo显示内存信息cpuinfo显示cpu信息wifi显示wifi信息activity显......
  • NATAPP使用教程(内网穿透)
    NATAPP使用教程(内网穿透)https://blog.csdn.net/weixin_42601136/article/details/108836388 内网穿透(NATAPP)简易使用(!!!用这条链接最准确)https://betheme.net/news/txtli......