1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
struct DataList: View {
@State var search: String = ""
@Binding var dataList: [Item]
var dataSearchFilterList: [Item] {
dataList.filter({"\($0)".contains(search.lowercased()) || search.isEmpty})
}
var body: some View {
if dataSearchFilterList.isEmpty {
Text("搜索不到...")
} else {
... // 展示搜索结果
}
}
}
|