关于TextField值的变化将在Swiftui中发生变化
#100daysofcode #ios #swift #swiftui

当我们更改文本字段时,然后重视任何获得的值,那么此值将在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)
        }
    }
}

输出:

Image description