APP.vue文件中
<script>
export default {
data: function() {
return {
version: "1.5.4"//版本号
}
},
onLaunch: function() {
uni.getSystemInfo({
success: (res) => {
console.log(res.platform);
//检测当前平台,如果是安卓则启动安卓更新
if (res.platform == "android") {
this.AndroidCheckUpdate();
}
}
})
},
methods: {
AndroidCheckUpdate: function() {
var _this = this;
uni.request({
//version.txt中内容为版本号,如果版本号大于客户端的版本号,客户端就自动更新
url: 'http://122.227.76.90:11124/app/version.txt'