尝试将环境对象添加到预览中:
#if DEBUG struct CompetitionsListSwiftUIView_Previews : PreviewProvider { static var previews: some View { CompetitionsListSwiftUIView() .environmentObject(CompetitionsViewModel()) } } #endif