@Binding能夠跨view傳遞對象引用,可是如何初始化呢?
能夠在preview中生成一些測試數據,下面是兩種方法ide
struct RFSearchListView_Previews: PreviewProvider { @State static var items2:[String] = ["a","b"] static var previews: some View { RFSearchListView(items: $items2) } }
struct RFSearchListView_Previews: PreviewProvider { static var previews: some View { RFSearchListView(items: .constant(["a","b","C"])) } }