可以参考此demoimport { buffer } from '@kit.ArkTS'; @Entry @Component struct Index { @State message: string = 'Hello World'; str = 'base64A' strWithChinese = 'base64B' build() { RelativeContainer() { Button("解码").onClick((event: ClickEvent) => { let result = encodeURI(this.strWithChinese) console.log(buffer.from(result, "base64").toString("utf-8")) console.log(buffer.from(this.str, "base64").toString("utf-8")) }) } .height('100%') .width('100%') } }
可以参考此demo