更新时间: 试题数量: 购买人数: 提供作者:

有效期: 个月

章节介绍: 共有个章节

收藏
搜索
题库预览
已知下列代码PageOne页面为navigation中的某一子页面,依次点击PageOne页面中toPageTwo按钮,PageTwo页面中toPageOne按钮,此时点击get按钮获取全部名为name的NavDestination页面的位置索引为 /// PageOne.ets @Component export struct PageOneTmp { @Consume('pageInfos') pageInfo: NavPathStack; build() { NavDestination() { Column() { Button('toPageTwo', { stateEffect: true, type: ButtonType.Capsule }) .width('80%') .height(40) .margin(20) .onClick(() => { this.pageInfos.pushPathByName('pageTwo','') }) Button('get', { stateEffect: true, type: ButtonType.Capsule }) .width('80%') .height(40) .margin(20) .onClick(() => { console.log('获取全部名为name的NavDestination页面的位置索引', JSON.stringify(this.pageInfos.findIndexByName('pageOne'))) }) }.width('100%').height('100%') }.title('pageOne') .onBackPressed(() => { const popDestinationInfo = this.pageInfos.pop() console.log('pop' + '返回值' + JSON.stringify(popDestinationInfo)) return true }) } } // PageTwo.ets export class Pages { names: string = "" values: NavPathStack | null = null } @Builder export function pageTwoTmp(info: Pages) { NavDestination() { Column() { Button('toPageOne', { stateEffect: true, type: ButtonType.Capsule }) .width('80%') .height(40) .margin(20) .onClick(() => { (info.values as NavPathStack).pushPathByName('pageOne', null) }) Button('get', { stateEffect: true, type: ButtonType.Capsule }) .width('100%').height('100%') .onClick(() => { (info.values as NavPathStack).pop() return true }) } (单选题) }