我正在尝试使用SwiftUI为Apple Watch创建自定义的不和谐客户端。我必须为每个循环使用双精度来显示带有普通文本聊天(子通道)的标题通道(父通道)。运行代码时,我只获得每个循环的结果。有人知道如何解决吗?
struct ChannelsView: View {
var serverId: String
var body: some View {
List{
ForEach(NetworkHandler.parentChannels){parentChannel in
Text(parentChannel.name)
.font(.headline)
ForEach(parentChannel.childChannels){channel in
NavigationLink(destination: MessagesContentView(channelId: channel.id, channelName: channel.name)){
ChannelView(name: channel.name)
}
}
}
}
.navigationBarTitle("Channels")
.onAppear(){
NetworkHandler.getChannels(serverId: self.serverId)
}
}
}
谢谢