拉起【应用市场】的同时,并跳转到app的安装页面
import Want from '@ohos.app.ability.Want';
import common from '@ohos.app.ability.common';
@Entry
@Component
struct Index {
@State appId: string = '1111111111111';
controller: TextInputController = new TextInputController();
build() {
Row() {
Column() {
TextInput({ text: this.appId, placeholder: '请输入应用的appId', controller: this.controller })
.width('90%')
.onChange((value: string) => {
this.appId = value
})
Button('点击跳转到鸿蒙版应用市场详情页面')
.margin({top: 50})
.onClick(()=>{
const want: Want = {
uri: `store://appgallery.huawei.com/app/detail?id=C${this.appId}`
};
const context = getContext(this) as common.UIAbilityContext;
context.startAbility(want).then(()=>{
//拉起成功
}).catch(()=>{
// 拉起失败
});
})
}
.width('100%')
}
.height('100%')
}
}