Compose NavHost 跳转 注意点

2021-09-05  本文已影响0人  菜鸟何时起飞
  NavHost(
            navController = navController,
            startDestination = MainDestinations.HOME_PAGE_ROUTE,
        ){
            composable(MainDestinations.HOME_PAGE_ROUTE) {
                HomeContent()
            }
            composable(MainDestinations.LOGIN_ROUTE) {
                SignInScreen()
            }
            composable(MainDestinations.ABOUT_ME_ROUTE){
                AboutMeScreen()
                Log.i("cccccccccc","AboutMeScreen====$")
            }
            composable("${MainDestinations.ARTICLE_ROUTE}/{${MainDestinations.ARTICLE_ROUTE_URL}}"
                ,arguments = listOf(navArgument(MainDestinations.ARTICLE_ROUTE_URL){
                    type = NavType.StringType
                })){ backStackEntry->

                val arguments = requireNotNull(backStackEntry.arguments)
                val parcelable = arguments.getString(ARTICLE_ROUTE_URL)
                Log.i("cccccccccc","parcelable====$parcelable")
                val fromJson = Gson().fromJson(parcelable, ArticleBean::class.java)
//                ArticlePage(
//                    article = fromJson,
//                    onBack = actions.upPress
//                )
                Text("231231231")
            }
        }
image.png

主要就是这两个大括号的写法 不能漏

上一篇下一篇

猜你喜欢

热点阅读