中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
import { common } from '@kit.AbilityKit'; import { BusinessError } from '@kit.BasicServicesKit'; @Entry @Component struct Index { @State message: string = '111'; context = getContext(this) as common.UIAbilityContext build() { Button("appCrash").onClick(() => { try { this.context.terminateSelf((err: BusinessError) => { if (err.code) { console.error(`terminateSelf failed, code is \${err.code}, message is \${err.message}`); return; } console.info('terminateSelf succeed'); }); } catch (err) { let code = (err as BusinessError).code; let message = (err as BusinessError).message; console.error(`terminateSelf failed, code is \${code}, message is \${message}`); } }); } }