除了生成绑定到动态生成的视图模型列表的FormField视图(基于TextField)之外,我已经准备好了所有内容。如果我把FormField视图换成普通的文本视图,它就能正常工作(见截图): ForEach(viewModel.viewModels) { vm in FormField(viewModel: $vm)
} 我曾尝试将ConfigurableFormViewModel
我有一个从名为List的整数数组创建的data视图,并使用绑定将数据传递给视图。我在将元素追加到withAnimation数组时使用data。some Scene { ContentView(data: $data) }但是,如果我将data数组放置到符合some Scene { ContentView(data: $d
我试图在forEach中修改数组中的值,但是我得到了一个错误:Cannot assign to property: 'place' is a 'let' constant和我不知道为什么。我的数组都是由var而不是let定义的.guard let location = locations.last else { return }
ForEach,然后在数组中添加当前用户
List { ForEach(viewModel.flight.flightEvents, id: \.id) { flightEvent in ..Identifiable { let id = UUID() let dateComponents: DateComponents此代码将导致flightEvents数组中的项立即绑定到列表但是,如果我将绑定到列表的集合更改为.
viewModel.flight.flightEven