Swift ForEach onDelete不使用LazyVStack

Swift ForEach onDelete不使用LazyVStack,swift,swiftui,Swift,Swiftui,ForEach onDelete不使用LazyVStack,但相同的代码可以很好地使用List。有什么想法吗?这里连刷卡都不行 NavigationView { ScrollView { LazyVStack(spacing: 5) { Section(footer: ListFooterView()) {

ForEach onDelete不使用LazyVStack,但相同的代码可以很好地使用List。有什么想法吗?这里连刷卡都不行

NavigationView {
        
        ScrollView {
            
            LazyVStack(spacing: 5) {
                
                Section(footer: ListFooterView()) {
                    ForEach(items.wrappedValue) { item in
                        
                        ZStack {
                            if  item.isNewItem {
                                NavigationLink(destination: EditItemView(item: item)) {
                                    ItemRowView(item: item)
                                }
                            }else {
                                NavigationLink(destination: ItemDetailView(item: item)) {
                                    ItemRowView(item: item)
                                }
                            }
                        }
                        
                    }.onDelete { offsets in
                        
                        let allItems = items
                        
                        for offset in offsets {
                            let item = allItems.wrappedValue[offset]
                            dataController.delete(item)
                        }
                        
                        dataController.save()
                    }
                }
                
            }
            
        }

您在列表中看到的是列表功能,而不是
onDelete
。这回答了你的问题吗?我认为onDelete不是列表功能,而是Foreach功能,理想情况下,无论我们在哪里使用Foreach,我们都应该能够使用onDelete。如果我们看到ForEach的文档,它确认了一个具有此委托功能的协议。这是我发布这个问题的主要疑问。