我有以下代码。当我清除视图模型上的TextField
绑定属性时,占位符文本将不会再次显示,直到struct SomeView: View {
@ObservedObject var viewModel = ViewModel()
var body: some View {
HStack {
TextField("Enter something here..", text: $viewModel.text)
.textFieldStyle(RoundedBorderTextFieldStyle())
.disableAutocorrection(true)
Spacer()
Button("Reset") { self.viewModel.reset() }
}
.padding()
}
}
class ViewModel: ObservableObject {
@Published var text = ""
func reset() {
text = ""
}
}
再次成为第一响应者为止。
'use strict';
// Google Cloud PubSub
const {PubSub} = require('@google-cloud/pubsub');
// Creates a client; cache this for further use
const pubSubClient = new PubSub();