美文网首页
Compose NavHost 跳转 注意点

Compose NavHost 跳转 注意点

作者: 菜鸟何时起飞 | 来源:发表于2021-09-05 19:29 被阅读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

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

    相关文章

      网友评论

          本文标题:Compose NavHost 跳转 注意点

          本文链接:https://www.haomeiwen.com/subject/fcxswltx.html