- 发布:2024-10-17 09:05
- 更新:2024-10-30 13:11
- 阅读:250
产品分类: uni小程序SDK
手机系统: 全部
页面类型: vue
SDK版本号: 2.3.2
测试过的手机:
示例代码:
import { openUniMP,isExistsUniMP, releaseWgtToRunPath } from '@dcloudio/uni-app-runtime';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Text(this.message)
.id('HelloWorld')
.fontSize(50)
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: 'container', align: VerticalAlign.Center },
middle: { anchor: 'container', align: HorizontalAlign.Center }
})
.onClick(async ()=>{
const mpId = "UNI77E0B0B"
await new Promise<void>((resolve, reject) => {
try {
// 判断应用是否已释放到运行目录
let isExists = isExistsUniMP(mpId)
console.log("isExists:"+isExists)
// 拼接wgt包路径
let path = getContext().resourceDir + "/"+mpId+".wgt"
// 释放 wgt 包到运行目录
releaseWgtToRunPath(mpId,path, (code:number, data: object)=>{
console.log(JSON.stringify({code,data}))
resolve()
})
} catch(err){
reject(err)
}
})
// 启动小程序
const mp = openUniMP(mpId,{redirectPath:"pages/index/index?a=1212"})
mp.on('uniMPEvent', (event:string, data:object, notify) => {
console.log(`----宿主收到小程序消息,事件:${event},消息:${JSON.stringify(data)}`);
notify('宿主成功接收小程序消息')
mp.on('close',()=>{
console.log('----------UniMP-close')
})
mp.close()
})
mp.on('close',()=>{
console.log('UniMP-close')
})
mp.on('show',()=>{
console.log('UniMP-show')
})
mp.on('hide',()=>{
console.log('UniMP-hide')
})
})
}
.height('100%')
.width('100%')
}
}
import { openUniMP,isExistsUniMP, releaseWgtToRunPath } from '@dcloudio/uni-app-runtime';
@Entry
@Component
struct Index {
@State message: string = 'Hello World';
build() {
RelativeContainer() {
Text(this.message)
.id('HelloWorld')
.fontSize(50)
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: 'container', align: VerticalAlign.Center },
middle: { anchor: 'container', align: HorizontalAlign.Center }
})
.onClick(async ()=>{
const mpId = "UNI77E0B0B"
await new Promise<void>((resolve, reject) => {
try {
// 判断应用是否已释放到运行目录
let isExists = isExistsUniMP(mpId)
console.log("isExists:"+isExists)
// 拼接wgt包路径
let path = getContext().resourceDir + "/"+mpId+".wgt"
// 释放 wgt 包到运行目录
releaseWgtToRunPath(mpId,path, (code:number, data: object)=>{
console.log(JSON.stringify({code,data}))
resolve()
})
} catch(err){
reject(err)
}
})
// 启动小程序
const mp = openUniMP(mpId,{redirectPath:"pages/index/index?a=1212"})
mp.on('uniMPEvent', (event:string, data:object, notify) => {
console.log(`----宿主收到小程序消息,事件:${event},消息:${JSON.stringify(data)}`);
notify('宿主成功接收小程序消息')
mp.on('close',()=>{
console.log('----------UniMP-close')
})
mp.close()
})
mp.on('close',()=>{
console.log('UniMP-close')
})
mp.on('show',()=>{
console.log('UniMP-show')
})
mp.on('hide',()=>{
console.log('UniMP-hide')
})
})
}
.height('100%')
.width('100%')
}
}
操作步骤:
鸿蒙系统的uni小程序sdk,最新版的依赖2.3.2,右滑关闭,主动调用关闭小程序包会报错
鸿蒙系统的uni小程序sdk,最新版的依赖2.3.2,右滑关闭,主动调用关闭小程序包会报错
预期结果:
返回app原页面
返回app原页面
实际结果:
app报错崩溃
app报错崩溃
bug描述:
鸿蒙系统的uni小程序sdk,最新版的依赖2.3.2,右滑关闭,主动调用关闭小程序包会报错,导致app崩溃。依赖更新日志上2.2.0这个版本可以,为什么已修复的bug,最新版又出现了。
3***@qq.com (作者)
新版本的目前不会了
2024-11-12 14:17