我可以忽略代码中的“twitter bootstrap is deprecated”警告吗?(Can I ignore the “twitter bootstrap is deprecated” wa

编程入门 行业动态 更新时间:2024-10-26 15:27:12
我可以忽略代码中的“twitter bootstrap is deprecated”警告吗?(Can I ignore the “twitter bootstrap is deprecated” warnings in my code?)

我使用的是与2.0的Bootstrap 3.3.4玩框架2.3.8,并在我的应用程序中有几种形式,您可以在其中输入输入。

样品:

@import models.Question @import models.Answer @import helper._ @import helper.twitterBootstrap._ @(questionForm: Form[Question], questionList: List[Question]) @main("Ask Question"){ @helper.form(action = routes.Application.sendQuestion()){ <fieldset> @helper.inputText(questionForm("questionID")) @helper.inputText(questionForm("questionText")) @helper.inputText(questionForm("voteScore")) @helper.inputText(questionForm("userID")) @helper.inputText(questionForm("page")) </fieldset> <input type="submit" class="btn btn-default"> } }

现在,如果我编译,在终端中有几个警告:

[warn] @helper.inputText(questionForm("userID")) [warn] ^ [warn] (...)\frageAntwort.scala.html:22: value twitterBootstrapField in package twitterBootstrap is deprecated: The twitter bootstrap field constructor will be removed from Play in 2.4 since the way Bootstrap must be used changes too frequently and too drastically between versions for this to make sense to be in the core of Play

我搜索了这个警告,只发现了这个旧的关于它的帖子和github上的一个问题 。

SO帖子提到写他自己的模板助手,但作为我自己的工作,我看到没有必要写一个。 那么我是否仍然可以使用我的产品并忽略这些警告,或者稍后在我的生产系统或其他任何地方发现问题? 另外,如果警告没有后果,是否有办法隐藏它们?

I am using the play framework 2.3.8 with twitter Bootstrap 3.3.4 and have several forms in my application, where you can enter input.

Sample:

@import models.Question @import models.Answer @import helper._ @import helper.twitterBootstrap._ @(questionForm: Form[Question], questionList: List[Question]) @main("Ask Question"){ @helper.form(action = routes.Application.sendQuestion()){ <fieldset> @helper.inputText(questionForm("questionID")) @helper.inputText(questionForm("questionText")) @helper.inputText(questionForm("voteScore")) @helper.inputText(questionForm("userID")) @helper.inputText(questionForm("page")) </fieldset> <input type="submit" class="btn btn-default"> } }

Now, if I compile, there are several warnings in the terminal:

[warn] @helper.inputText(questionForm("userID")) [warn] ^ [warn] (...)\frageAntwort.scala.html:22: value twitterBootstrapField in package twitterBootstrap is deprecated: The twitter bootstrap field constructor will be removed from Play in 2.4 since the way Bootstrap must be used changes too frequently and too drastically between versions for this to make sense to be in the core of Play

I've searched for the warning and only found this old SO post about it and an issue on github.

The SO post mentions to write his own template helper, but as my own is working I see no need yet to write one. So can I still use mine and ignore the warnings, or will I get into trouble later in my productive system or anywhere else? Also if the warnings have no consequences, is there a way to hide them?

最满意答案

在Play 2.3迁移指南中有一部分旨在解释这个问题。 它说:

内置的Twitter Bootstrap字段构造函数已被弃用,并且将在未来版本的Play中删除。

这其中有几个原因,其中一个原因是我们发现Bootstrap在版本之间的变化过于频繁,因此Play提供的任何内置支持很快就会变得陈旧且与当前的Bootstrap版本不兼容。

另一个原因是当前Bootstrap对CSS类的要求无法单独使用Play的字段构造函数实现,因此还需要自定义输入模板。

我们的观点是,如果这是一个对社区有价值的功能,可以创建第三方模块,它提供了一组独立的Bootstrap表单助手模板,特定于Bootstrap版本,允许更好的用户体验目前提供。

即使它现在有效,将来也会出现问题。 如果我是你,我会为编写定制解决方案而奔波。 只有这样,你才能确保在你的项目中进行了框架升级之后,一切仍然可以正常工作。

In the Play 2.3 migration guide there's a section intended to explain that issue. It says that:

The in-built Twitter Bootstrap field constructor has been deprecated, and will be removed in a future version of Play.

There are a few reasons for this, one is that we have found that Bootstrap changes too drastically between versions and too frequently, such that any in-built support provided by Play quickly becomes stale and incompatible with the current Bootstrap version.

Another reason is that the current Bootstrap requirements for CSS classes can’t be implemented with Play’s field constructor alone, a custom input template is also required.

Our view going forward is that if this is a feature that is valuable to the community, a third party module can be created which provides a separate set of Bootstrap form helper templates, specific to given Bootstrap versions, allowing a much better user experience than can currently be provided.

Even if it works now there can be a problem in the future. If I were you, I'd plunk for writing a custom solution. Only that way you can be sure that after framework upgrade in your project everything will still work fine.

更多推荐

本文发布于:2023-08-06 23:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457616.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   bootstrap   twitter   deprecated   warnings

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!