路由跳转到一个只有页面没有UIAbility的模块:
- 现在有模块A,B。A模块为Entry类型,其中有个UIAbility,有pages。B模块是Feature类型,没有UIAbility,但是有pages。整个App只想使用一个UIAbility的情况下,A模块跳转到B模块的页面并且带参数。
案例
- 项目/entry/src/main/resources/base/profile/main_pages.json
{
"src": [
"pages/Index",
"pages/SubPag" // 添加页面
]
}
- Index.ets
import { router } from '@kit.ArkUI'
@Entry
@Component
struct Index {
build(){
Button('点击跳转页面').onClick((event: ClickEvent) => {
router.pushUrl({
url: 'pages/SubPag',
params: {
userName: 'zs'
}
})
})
}
}
- SubPag.ets
import { router } from '@kit.ArkUI';
interface UserVO {
userName: string;
}
@Entry
@Component
struct SubPag {
@State message: string = 'Hello World';
aboutToAppear(): void {
let params = router.getParams() as UserVO;
console.log('params参数 === ', JSON.stringify(params));
}
build() {
Text('hello')
}
}
网友评论