行VStack显示错误"实例方法‘Sheet(Item:onDismi:Content:)’要求‘Int’符合‘IDENTABLE’",但我想我没有犯任何错误?我有吗?
我感觉我的工作表出错了,我的Int应该符合‘可识别的’,但Int不是‘可识别的’,因为它是原始的?我该如何解决这个问题呢?
struct SheetView: View {
@State var bindingItemDiscounts: [Double] =
[ 0.99, 0.25, 0.31, 11.99, 19.99, 0.1, 0.5]
@State var discountMoreThanTen: Int?
var body: some View {
VStack(alignment: .leading) { <- this line
Button {
discountMoreThanTen = bindingItemDiscounts.count
} label: { Text("Check Discounts") }
}.sheet(item: $discountMoreThanTen) { newValue in
if discountMoreThanTen ?? 0 <= 10 {
List(bindingItemDiscounts, id: \.self) { discount in
Text("Discount : \(discount)")
}
}
}
}
}.