struct ContentView: View {
// @ObservedObject var user = User()
@EnvironmentObject var user: User
init(){
user.username = "yy"
}
我想更改init()中的EvironmentObject值 因为我想要数据预处理
但是此代码有错误
Thread 1: Fatal error: No ObservableObject of type User found. A View.environmentObject(_:) for User may be missing as an ancestor of this view.
如何在View的初始化中访问EnvironmentObject?