可以参考以下代码解压缩:import fs from '@ohos.file.fs'; import { BusinessError } from '@kit.BasicServicesKit'; import { unzipToDirectory } from '@ohos/minizip' @Entry @Component struct Page { @State context:Context =getContext(this); build() { Column() { Row() { Button('jszip unzip testpwd').onClick(() => { const content = this.context.resourceManager.getRawFileContentSync("testpwd.zip"); let file2 = fs.openSync(this.context.filesDir + '/testpwd.zip', fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); fs.writeSync(file2.fd, content.buffer); fs.close(file2); unzipToDirectory(this.context.filesDir + '/testpwd.zip', this.context.filesDir + '/unziptestpwd', '123456').then((result) => { console.log(result); }).catch((err: BusinessError) => { console.log(err.message); }); }) } .width('100%') } .height('100%') } }
可以参考以下代码解压缩: