static async openSystemBrowser(url: string) {
   if (url) {
     try {
       let want = {
         // uncomment line below if wish to implicitly query only in the specific bundle.
         // bundleName: "com.example.myapplication",
         "action": "ohos.want.action.viewData",
         // entities can be omitted.
         "entities": ["entity.system.browsable"],
         "uri": url,
         "type": "text/plain"
       }
       let context = getContext(this) as common.UIAbilityContext;
       await context.startAbility(want)
       console.info(`explicit start ability succeed`)
     } catch (error) {
       console.info(`explicit start ability failed with ${error.code}`)
     }
   }
 }

更多推荐