当没有提交按钮时,表单不会在回车键上提交(form is not submitted on enter key when there is no submit button inside)
有没有解决这个问题
<form> <input type="text" ... </form>
在没有提交表单的情况下,在文本框内按下Enter键不会提交表单,是否有一些解决方法?
is there some fix for this
<form> <input type="text" ... </form>
hitting the enter key inside the textfield when there is no submit button inside doesn't submit the form, is there some fix for this ?
原文:https://stackoverflow.com/questions/3132488
最满意答案
这不是一个错误。 简短的答案是协议扩展不会引入动态分派。 有关更全面的解释,请参阅此答案 。 这里的解释非常详尽,并且包含一个例子。
这里有一篇博文更加深入: https : //nomothetis.svbtle.com/the-ghost-of-swift-bugs-future
This is not a bug. The short answer is that protocol extensions to not introduce dynamic dispatch. For a more thorough explanation, see this answer. The explanation there is quite thorough and contains an example.
Here is a blog post that dives even more deeply: https://nomothetis.svbtle.com/the-ghost-of-swift-bugs-future
相关问答
更多-
我有一个协议,其函数可以返回String或[String:String]。 这是我的声明: 没问题。 让我们写下来。 enum StringOrDictionary { case string(String) case dictionary([String: String]) } protocol Test { func returnSomething() -> StringOrDictionary } 然后我想要一个returnSomething的默认实现,所以我做了一个协议扩 ...
-
找不到协议声明(Cannot find protocol declaration)[2024-03-15]
正如你所说MyPocketAppDelegate是你的应用程序委托类,它不能被采纳或符合。 协议和类是两个不同的东西。 你应该从协议列表中删除它。 @interface Paypal : UIViewController{ As you say MyPocketAppDelegate is your application delegate class, it cannot be adopted or conformed. Protocols and clas ... -
简答: 不,这是不可能的 。 您最多可以强制实施方法和属性。 Short answer: No, it isn't possible to do that. You can enforce the availability of methods and properties at most.
-
基于类型声明的协议实现行为的差异[复制](Difference in protocol implementation behavior based on type declaration [duplicate])[2023-11-21]
这不是一个错误。 简短的答案是协议扩展不会引入动态分派。 有关更全面的解释,请参阅此答案 。 这里的解释非常详尽,并且包含一个例子。 这里有一篇博文更加深入: https : //nomothetis.svbtle.com/the-ghost-of-swift-bugs-future This is not a bug. The short answer is that protocol extensions to not introduce dynamic dispatch. For a more tho ... -
弄清楚:不确定是什么搞砸了,但结果是卸载然后重新安装WCF非HTTP激活修复了它。 Figured it out: Not sure what was messed up, but turns out that uninstalling then reinstalling WCF Non-HTTP Activation fixed it.
-
如何使用类型约束调用协议扩展默认实现(How to invoke protocol extension default implementation with type constraints)[2023-07-10]
为类型转换创建一个空的类 class ManObj { func baseFunc() { print("ManObj baseFunc") } } class SubObj: ModelCaster { func someFunc() { print("SubObj Implementation") } } protocol Model { } extension Model where Self: ModelCaster { // T ... -
在Objective-C中,协议不是一种类型。 您应该声明符合协议的类,如下所示: id
p = [[ObjCClass alloc] init]; 你的前向声明编译的原因是因为这是前向声明的作用 - 它们向编译器宣告一个类存在,并且链接器将在稍后的构建过程中填充它。 (这就是改为id p =...的原因。) 在Swift中,我们用类似的东西声明类: class MyClass : Superclass, Protocol, AnotherProtocol { ... } 在O ... -
所以我该怎么做? 你应该重新考虑你的设计。 听起来您希望在许多不同的类中采用此协议,以便您可以拥有每个类的共享实例。 这些物品真的需要单身吗? 共享对象和不能多次实例化的类之间存在差异。 考虑创建一个充当所有其他类的工厂的类。 该类可以维护共享对象的字典,您可以简单地指出始终使用工厂来实例化其他类。 实际上,您可以编写其他类,直接实例化它们会抛出异常或其他类。 So, what should I do? You should reconsider your design. It sounds like yo ...
-
原来是删除线 typealias BarType = Bar 解决了这个问题。 哪种是公平的类型推断能够完成它的工作。 然而,它应该是一个合法的代码,似乎是编译器中的一个错误。 据此报道 。 Turns out that removing the line typealias BarType = Bar resolves the issue. Which is fair - type inference does its job. Nevertheless, it should be a legal c ...
-
工厂只需要声明复制ctor而不实施(Factory requires only declaration of copy ctor without implementation)[2022-04-21]
编译器会删除实际的副本,因为可以访问复制构造函数,所以允许使用该副本。 编译器当然没有义务忽略这个副本,如果没有,我会期望链接器错误找不到拷贝构造函数的实现。 The actual copy is elided by the compiler, which is allowed since the copy constructor is accessible. The compiler is of course under no obligation to elide this copy and if it ...