请参考demoimport { common, Want } from '@kit.AbilityKit'; @Entry @Component struct liulanqi { @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(() => { }) Button("拉起浏览器").onClick(() => { let context = getContext(this) as common.UIAbilityContext; let want: Want = { action: "ohos.want.action.viewData", bundleName: 'com.huawei.hmos.browser', abilityName: 'MainAbility', uri: "https://www.huawei.com/", }; console.log("want", want) context.startAbility(want) }).margin(10) } .height('100%') .width('100%') } }
请参考demo