在fragment中使用如下代码,报错
import androidx.fragment.app.viewModels
private val levelMapViewModel: LevelMapViewModel by viewModels()
1.添加依赖
implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
2.添加设置
kotlinOptions { // work-runtime-ktx 2.1.0 and above now requires Java 8 jvmTarget = "1.8" }
3.查看IDE

更新Gradle,解决!