有没有办法将参数从 NavHostController 传递给 ViewModel?

Is there a way to pass an argument from NavHostController to ViewModel?

如何将 argumentNavHostController 传递到我的 ViewModel init{}

我真的不明白 SQL 查询与这里有什么关系。要将导航参数中的参数传递给视图模型,您必须使用 SavedStateHandle。然后你可以使用 get() 或 getLiveData()。键将等于参数名称。 https://developer.android.com/topic/libraries/architecture/viewmodel-savedstate