實例方法
submit
submitScope(_:)
防止源自此視圖的提交觸發器調用由視圖層次結構中較高的提交修飾符配置的提交操作。
聲明
func submitScope(_ isBlocking: Bool = true) -> some View
參數
isBlocking
一個布爾值,指示此範圍是否主動阻止提交觸發器達到更高的提交操作。
詳述
當您希望避免特定視圖啟動由 View/onSubmit(of:_:)
修飾符配置的提交操作時,請使用此修飾符。在下麵的示例中,標簽字段不會觸發表單的提交:
Form {
TextField("Username", text: $viewModel.userName)
SecureField("Password", text: $viewModel.password)
TextField("Tags", text: $viewModel.tags)
.submitScope()
}
.onSubmit {
guard viewModel.validate() else { return }
viewModel.login()
}
可用版本
iOS 15.0+, iPadOS 15.0+, macOS 12.0+, Mac Catalyst 15.0+, tvOS 15.0+, watchOS 8.0+
相關用法
- Swift Never submitLabel(_:)用法及代碼示例
- Swift Never suggestedFileName(_:)用法及代碼示例
- Swift Never saturation(_:)用法及代碼示例
- Swift Never simultaneousGesture(_:including:)用法及代碼示例
- Swift Never symbolVariant(_:)用法及代碼示例
- Swift Never scaledToFill()用法及代碼示例
- Swift Never safeAreaInset(edge:alignment:spacing:content:)用法及代碼示例
- Swift Never searchCompletion(_:)用法及代碼示例
- Swift Never sheet(isPresented:onDismiss:content:)用法及代碼示例
- Swift Never scaleEffect(x:y:anchor:)用法及代碼示例
- Swift Never speechAlwaysIncludesPunctuation(_:)用法及代碼示例
- Swift Never sheet(item:onDismiss:content:)用法及代碼示例
- Swift Never scaleEffect(_:anchor:)用法及代碼示例
- Swift Never scaledToFit()用法及代碼示例
- Swift Never shadow(color:radius:x:y:)用法及代碼示例
- Swift Never swipeActions(edge:allowsFullSwipe:content:)用法及代碼示例
- Swift Never scenePadding(_:)用法及代碼示例
- Swift Never pageCommand(value:in:step:)用法及代碼示例
- Swift Never opacity(_:)用法及代碼示例
- Swift Never colorMultiply(_:)用法及代碼示例
- Swift Never accessibilityAction(action:label:)用法及代碼示例
- Swift Never alert(isPresented:error:actions:message:)用法及代碼示例
- Swift Never confirmationDialog(_:isPresented:titleVisibility:actions:)用法及代碼示例
- Swift Never flipsForRightToLeftLayoutDirection(_:)用法及代碼示例
- Swift Never position(x:y:)用法及代碼示例
注:本文由純淨天空篩選整理自apple.com大神的英文原創作品 Never submitScope(_:)。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。