-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* 判断版本号大小:1.2.3a和1.2.4b,后者大 | ||
*/ | ||
var vSort = function(v1, v2) { | ||
var vtf1 = parseFloat(v1); | ||
var vtf2 = parseFloat(v2); | ||
console.log(vtf1, vtf2); | ||
var vtr1 = v1.replace(vtf1 + ".",""); | ||
var vtr2 = v2.replace(vtf2 + ".",""); | ||
console.log(vtr1, vtr2); | ||
if(vtf1 > vtf2){ | ||
return true; | ||
}else if(vtf1 < vtf2){ | ||
return '前者小'; | ||
}else{ | ||
if(vtr1 >= vtr2){ | ||
return '前者大'; | ||
}else{ | ||
return '前者小'; | ||
} | ||
} | ||
} | ||
vSort('1.2.4b', '1.2.4a') |