2

我想在 jetpack compose 导航中传递一个 url 字符串作为参数。问题是:斜杠(“/”)抛出异常,因为导航使用斜杠分隔参数并且没有找到正确的路线。

composable(
    route = "Home/{url}",
    arguments = listOf(
        navArgument("url") {
            type = NavType.StringType
        }
    )
)

然后,如果我尝试导航,它会引发异常:

val url = "random.com/get/object"
navController.navigate("Home/${url}")
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/Home/random.com/get/object } cannot be found in the navigation graph NavGraph

有没有办法在 Jetpack Compose Navigation 中使用斜杠(“/”)传递字符串参数?

4

0 回答 0