为什么要使用< g:textField/>在Grails中? [英] Why use <g:textField /> in Grails?

查看:287
本文介绍了为什么要使用< g:textField/>在Grails中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您已经熟悉标准HTML表单标记,那么在Grails中使用g:textField的原因是什么?

What is the reason to use g:textField in Grails if you're already familiar with standard HTML form tags?

如果我正确理解以下两种标记替代方法,则是等效的:

If I understand correctly the following two markup alternatives are equivalent:

<input type="text" name="name" value="${params.name}" id="name" />
<g:textField name="name" value="${params.name}" />

在任何情况下,使用g:textField都会增加价值吗?我想念什么吗?

Are there any circumstances under which using g:textField would add value? Am I missing something?

推荐答案

为方便起见,提供了textField标记(比编写HTML输入要短一些),并在那里提供了完整的form标记集.就我个人而言,我更喜欢在Grails视图中编写尽可能多的纯HTML,并且仅倾向于使用真正提供好处的标签,例如form标签.我还没有找到一个实例,使用textField可以在不需要输入几个字符的情况下添加任何值.

The textField tag is provided as a convenience (slightly shorter than writing the HTML input) and is there to provide a full set of form tags. Personally I prefer to write as much plain HTML as possible in my Grails views and only tend to use the tags that really offer a benefit such as the form tag. I have not found an instance where using textField would have added any value outside of requiring a few less characters to type.

这篇关于为什么要使用&lt; g:textField/&gt;在Grails中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆