当我们更改文本字段时,然后重视任何获得的值,那么此值将在swift
中更改代码如下:
import SwiftUI
struct User{
var firstName = "Saurabh"
var lastName = "Chavan"
}
struct ContentView: View {
@State private var Users = User()
var body: some View{
VStack{
Text("\(Users.firstName) \(Users.lastName)")
TextField("First Name", text: $Users.firstName)
TextField("Last Name", text: $Users.lastName)
}
}
}
输出: