呈现后swiftui页面为空白

呈现后swiftui页面为空白,swiftui,swiftui-list,Swiftui,Swiftui List,我对视图有问题。有问题的视图一旦进入其中,渲染屏幕一会儿,然后消失。我从firebase加载数据。在层级层次上,它是第三个视图 视图A->视图B->视图C 如果从B到C,我有问题,如果从A到问题,它不存在 问题是onAppear返回空后的“self.lineup.fetchHomeTeam” 从ViewB传递到ViewC的数据是正确的 视图C(团队模块视图)->有问题的页面 struct TeamsModuleView: View { @ObservedObject var lineu

我对视图有问题。有问题的视图一旦进入其中,渲染屏幕一会儿,然后消失。我从firebase加载数据。在层级层次上,它是第三个视图

视图A->视图B->视图C

如果从B到C,我有问题,如果从A到问题,它不存在

问题是onAppear返回空后的“self.lineup.fetchHomeTeam” 从ViewB传递到ViewC的数据是正确的

视图C(团队模块视图)->有问题的页面

struct TeamsModuleView: View {

    @ObservedObject var lineup = LineupViewModel()
    @EnvironmentObject var settings: UserSettings

    var body: some View {
        ScrollView(.vertical) {
            Group {
                VStack(spacing: 20, content:  {
                    ForEach(lineup.lineupHome, id: \.self) { module in
                        HStack(alignment: .top, spacing: 10, content: {
                            ForEach(module.name, id: \.self) { name in
                                Group {
                                    Spacer()
                                    VStack(alignment: .center, spacing: 0, content: {
                                        Spacer().frame(height: 20)
                                        Image("home")
                                            .resizable()
                                            .frame(width: 30, height: 30)
                                        Text(name)
                                            .foregroundColor(Color.white)
                                            .font(.system(size: 10))
                                            .frame(maxWidth: .infinity,  alignment: .center)
                                            .multilineTextAlignment(.center)
                                        Spacer().frame(height: 5)
                                    })
                                    Spacer()
                                }
                            }
                        })
                    }
                    ForEach(lineup.lineupAway, id: \.self) { module in
                        HStack(alignment: .top, spacing: 10, content: {
                            ForEach(module.name, id: \.self) { name in
                                Group {
                                    Spacer()
                                    VStack(alignment: .center, spacing: 0, content: {
                                        Spacer().frame(height: 5)
                                        Image("transfert")
                                            .resizable()
                                            .frame(width: 30, height: 30)
                                        Text(name)
                                            .foregroundColor(Color.white)
                                            .font(.system(size: 10))
                                            .frame(maxWidth: .infinity,  alignment: .center)
                                            .multilineTextAlignment(.center)
                                        Spacer().frame(height: 20)
                                    })
                                    Spacer()
                                }
                            }
                        })
                    }                        
                })
                .background(
                    Image("field3")
                        .resizable()
                        .aspectRatio(contentMode: .fill)
                ).edgesIgnoringSafeArea(.all)
            }
        }.onAppear  {
            self.lineup.fetchHomeTeam(fixturesId: String(self.settings.fixtureId), teamId: String(self.settings.teamHomeId), team: self.settings.teamHome)
            self.lineup.fetchAwayTeam(fixturesId: String(self.settings.fixtureId), teamId: String(self.settings.teamAwayId), team: self.settings.teamAway)
        }.onDisappear {
            print(self.lineup.lineupHome.isEmpty)
        }
        .navigationBarTitle("Formazione", displayMode: .inline) //Return true i dont why
    }
}

struct TeamsModuleView_Previews: PreviewProvider {

    static var previews: some View {        
        TeamsModuleView()
    }
}
LineupViewModel

final class LineupViewModel: ObservableObject {

    @Published var lineup = Lineup()
    @Published var lineupHome = [LineupView]()
    @Published var lineupAway = [LineupView]()


    func fetchHomeTeam(fixturesId: String, teamId: String, team: String) {
        Webservices().getLineUp(fixturesId: fixturesId, teamId: teamId, team: team) {
            self.lineup = $0
            var lineupModTemp = [LineupView]()
            -
            -
            -
            DispatchQueue.main.async {

                self.lineupHome = lineupModTemp
            }
        }
    }

    func fetchAwayTeam(fixturesId: String, teamId: String, team: String) {
        Webservices().getLineUp(fixturesId: fixturesId, teamId: teamId, team: team) {
            self.lineup = $0
            var lineupModTemp = [LineupView]()
            -
            -
            -
            DispatchQueue.main.async {
              self.lineupAway = lineupModTemp
            }
        }
    }
}
用户设置(实际数据在视图B onclik中修改)

class UserSettings: ObservableObject {
    @Published var teamHomeId = 505
    @Published  var teamAwayId = 518
    @Published  var teamHome = "Brescia"
    @Published  var teamAway = "Inter"
    @Published  var fixtureId = 232614
}