我想獲取在 SwiftUI 的 TextEditor 中輸入的字串并將其存盤在一個陣列中。我應該如何附加到文本資料?
struct TextEditorTest: View {
@State var textdata: [String] = []
@State var text1: String = ""
var body: some View {
TextEditor (text: $text1)
}
}
uj5u.com熱心網友回復:
@State var textdata: [String] = []
@State var text1: String = ""
var body: some View {
TextEditor (text: $text1)
.onChange(of: text1) { newValue in
print(newValue)
//perform your logic here because it will trigger as soon as value is changed in field
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/485212.html
