plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
uni.request({
url: "xxxxx",
data: {
version: widgetInfo.version,
name: widgetInfo.name,
},
method:"POST",
success: (result) => {
var data = result.data.data;
if(data.update != false){
uni.downloadFile({
url: data.wgtUrl,
success: (res) => {
console.log(res);
if (res.statusCode === 200) {
plus.runtime.install(
res.tempFilePath,
{
force: false,
},
function () {
console.log("install success...");
plus.runtime.restart();
},
function (e) {
console.log(e);
}
);
}
},
});
}
},
});
});
- 发布:2021-06-29 18:06
- 更新:2022-09-23 13:49
- 阅读:1229
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: win10
HBuilderX类型: 正式
HBuilderX版本号: 3.1.18
手机系统: iOS
手机系统版本号: IOS 14
手机厂商: 苹果
手机机型: IPhone11
页面类型: vue
打包方式: 离线
项目创建方式: HBuilderX
示例代码:
操作步骤:
plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
uni.request({
url: "xxxxx",
data: {
version: widgetInfo.version,
name: widgetInfo.name,
},
method:"POST",
success: (result) => {
var data = result.data.data;
if(data.update != false){
uni.downloadFile({
url: data.wgtUrl,
success: (res) => {
console.log(res);
if (res.statusCode === 200) {
plus.runtime.install(
res.tempFilePath,
{
force: false,
},
function () {
console.log("install success...");
plus.runtime.restart();
},
function (e) {
console.log(e);
}
);
}
},
});
}
},
});
});
plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
uni.request({
url: "xxxxx",
data: {
version: widgetInfo.version,
name: widgetInfo.name,
},
method:"POST",
success: (result) => {
var data = result.data.data;
if(data.update != false){
uni.downloadFile({
url: data.wgtUrl,
success: (res) => {
console.log(res);
if (res.statusCode === 200) {
plus.runtime.install(
res.tempFilePath,
{
force: false,
},
function () {
console.log("install success...");
plus.runtime.restart();
},
function (e) {
console.log(e);
}
);
}
},
});
}
},
});
});
预期结果:
console.log("install success..."); plus.runtime.restart();
console.log("install success..."); plus.runtime.restart();
实际结果:
function (e) {
console.log(e);
}
function (e) {
console.log(e);
}
bug描述:
获取到wgt文件进行下载
"tempFilePath": "_doc/uniapp_temp_1624960686754/download/1.wgt",
"statusCode": 200,
"errMsg": "downloadFile:ok"
但返回文件格式错误
"code": -1201,
"message": "WGT/WGTU文件格式错误,https://ask.dcloud.net.cn/article/282"
3 个回复
1***@qq.com
同 遇到 这问题 解决了吗
chenliang
这个问题后面处理了嘛
2***@qq.com - 辛德瑞拉
请问您解决这个问题了吗?