问题描述
注意问题:下载的wgt包的地址一定要存放在一个单独的文件目录里面,里面只包含一个wgt包!
解决方案:
提示:这里填写该问题的具体解决方案:
/** 升级app函数
* @param {Object} url wgt包在线地址
*/
updateApp(url) {
uni.showLoading({
title: "正在下载安装包...",
mask: true
})
uni.downloadFile({
url: url,
filePath: '_doc/update/' + new Date().getTime() + '/',
success: (downloadResult) => {
if (downloadResult.statusCode === 200) {
uni.showLoading({
title: "正在安装...",
mask: true
})
plus.runtime.install(downloadResult.tempFilePath, {
force: false
}, function() {
uni.hideLoading();
uni.showToast({
icon: 'success',
title: '安装成功'
})
console.log('install success...');
plus.runtime.restart();
}, function(e) {
uni.hideLoading();
uni.showToast({
icon: 'success',
title: '安装失败'
})
console.error('install fail...', e);
});
}
}
});
},