以编程方式清除时,TextField不显示占位符文本。有没有办法消除这种行为?

时间:2020-04-10 12:21:25

标签: swiftui

我有以下代码。当我清除视图模型上的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 = "" } } 再次成为第一响应者为止。 Demo Gif

'use strict';
// Google Cloud PubSub  
const {PubSub} = require('@google-cloud/pubsub');
// Creates a client; cache this for further use
const pubSubClient = new PubSub();

0 个答案:

没有答案