参考demo:@Component export struct PrivacyDialog { @Consume('pageInfo') pageStack : NavPathStack; @State isAgree: string = "Not Agree"; build() { NavDestination(){ Stack({ alignContent: Alignment.Center }){ // 蒙层 Column() { } .width("100%") .height("100%") .backgroundColor('rgba(0,0,0,0.5)') // 隐私弹窗 Column() { Text("注册应用账号").fontSize(30).height('20%') Text("请您仔细阅读一下协议并同意,我们将全力保护您的个人信息安全,您可以使用账号登录APP。").height('40%') Divider() Row(){ // 点击隐私条款,跳转到隐私条款页面,并接受隐私条款的返回值,用来刷新页面的同意状态。 Text("《应用隐私政策》").onClick(ent => { let pathInfo : NavPathInfo = new NavPathInfo('PrivacyItem', null , (popInfo: PopInfo) => { this.isAgree = popInfo.result.toString(); }) this.pageStack.pushDestination(pathInfo, true) }) Text(this.isAgree) }.height('20%') Divider() // 点击同意\不同意按钮,将状态返回登录页 Row(){ Button("不同意").onClick(ent => { this.pageStack.pop("Not Agree", true) }).width('30%') Button("同意").onClick(ent => { this.pageStack.pop("Agree", true) }).width('30%') }.height('20%') }.backgroundColor(Color.White) .height('50%') .width('80%') } }.hideTitleBar(true) // 设置Dialog类型 .mode(NavDestinationMode.DIALOG) } }
参考demo: