根据(有点官方)本指南,我可以制作单选按钮的标签,也可以选择该单选按钮.他们说,
始终为每个复选框和单选按钮使用标签.它们将文本与特定选项相关联,并提供更大的可点击区域.
不幸的是,我无法为我的表单获得此功能.这是我的代码:
<% form_for(@bet) do |f| %>
<%= f.label :bet_type %>
<%= f.radio_button :bet_type, "moneyline" %>
<%= f.label :bet_type_moneyline, "Moneyline" %>
<%= f.radio_button :bet_type, "spread" %>
<%= f.label :bet_type_spread, "Spread" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我也试过这个(因为这是使用FormTagHelper而不是FormHelper的示例):
<% form_for(@bet) do |f| %>
<%= radio_button_tag :bet_type, "moneyline" %>
<%= label_tag :bet_type_moneyline, "Moneyline" %>
<%= radio_button_tag :bet_type, "spread" %>
<%= label_tag :bet_type_spread, "Spread" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但是,我仍然无法让它发挥作用.我正在使用rails 2.3.5和ruby 1.8.7.
感谢阅读,也许还有帮助!
我已经enum.Enum与几个成员一起编写了一个类型。现在我想编写一个“选择器” ,它将返回基于参数@classmethod的成员之一,但我不知道如何正确输入提示。Enum
这是我到目前为止所要做的:
from enum import Enum, auto
from typing import TypeVar, Type
_StringSizeT = TypeVar("_StringSizeT", bound="StringSize")
class StringSize(Enum):
SMALL = auto()
BIG = auto()
@classmethod
def from_string(cls: Type[_StringSizeT], source_string: str) -> _StringSizeT:
n_chars = len(source_string)
if n_chars <= 10:
return cls.SMALL
return cls.BIG
Run Code Online (Sandbox Code Playgroud)
上面使用TypeVar()等 是我尝试遵循Martijn Pieters 在“当值是 cls 实例时可以注释返回类型吗?”中的帖子的方法。对于@classmethod工厂,但将它们应用于Enum @classmethod返回枚举成员之一的 s。
不幸的是,mypy 不喜欢我的 return 语句的类型:
error: Incompatible return value type (got "StringSize", expected "_StringSizeT") …Run Code Online (Sandbox Code Playgroud) 我在 zsh 中进行参数扩展时遇到了麻烦:它将我的变量括在引号中。
这是我的脚本。(对噪音表示歉意,唯一真正重要的一行是通话的最后一行find,但我想确保我没有隐藏代码的详细信息)
#broken_links [-r|--recursive] [<path>]
# find links whose targets don't exist and print them. If <path> is given, look
# at that path for the links. Otherwise, the current directory is used is used.
# If --recursive is specified, look recursively through path.
broken_links () {
recurse=
search_path=$(pwd)
while test $# != 0
do
case "$1" in
-r|--recursive)
recurse=t
;;
*)
if test -d "$1"
then
search_path="$1"
else
echo "$1 not a valid path or …Run Code Online (Sandbox Code Playgroud) HTMLElement元素的类型是什么,例如
<strong><cite><article>?
根据 MDN 的HTML 元素参考,元素比下面的类型多得多HTMLElement(请参阅此列表)。
我正在使用 TypeScript 对元素进行一些处理,并希望使用最具体的类型存储对它们的引用。虽然许多其他元素都清晰命名类型(例如HTMLDivElement,HTMLImageElement和HTMLTableElement),似乎我上面列出的元素不会有任何相应的类型。
html ×2
dom ×1
enums ×1
expansion ×1
javascript ×1
mypy ×1
parameters ×1
python ×1
quotes ×1
ruby ×1
type-hinting ×1
typescript ×1
webapi ×1
zsh ×1