List {
ForEach(transactions) { transaction in
HStack {
Circle()
.fill(transaction.color)
.frame(width: 20, height: 20)
.onTapGesture {
showTotalByColor.toggle()
}
Text(transaction.category)
Spacer()
Text(String(format: "$%.2f", transaction.amount))
Text(transaction.dateFormatted)
.foregroundColor(.gray)
}
}
.onDelete(perform: deleteTransaction)
}
提示有几个报错,分别是:
1,Cannot convert value 'transactions' of type '[Transaction]' to expected type 'Binding<[Transaction]>', use wrapper instead
2,Cannot assign to property: 'color' is a 'let' constant
3,Instance method 'fill(_:style:)' requires that 'Binding' conform to 'ShapeStyle'
不知道是什么原因呢?