我可以忽略“不推荐使用Twitter引导程序"吗?我的代码中的警告? [英] Can I ignore the "twitter bootstrap is deprecated" warnings in my code?

查看:107
本文介绍了我可以忽略“不推荐使用Twitter引导程序"吗?我的代码中的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Twitter Bootstrap 3.3.4的播放框架2.3.8,并且在我的应用程序中有几种形式,您可以在其中输入输入.

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.

示例:

@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.

SO帖子提到要编写自己的模板助手,但是由于我自己的模板助手正在工作,所以我认为还不需要编写模板助手.因此,我仍然可以使用我的产品而忽略警告吗,还是以后在生产系统或其他任何地方遇到麻烦?另外,如果警告没有后果,是否可以隐藏它们?

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?

推荐答案

播放2.3中迁移指南,其中有一部分旨在说明该问题.它说:

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

内置的Twitter Bootstrap字段构造函数已被弃用, 并将在以后的Play版本中删除.

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

有几个原因,一个是我们发现 Bootstrap在版本之间进行的更改过于频繁且过于频繁, 这样Play所提供的任何内置支持很快就会过时 并且与当前的Bootstrap版本不兼容.

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.

另一个原因是当前CSS的Bootstrap要求 类不能仅通过Play的字段构造函数来实现, 还需要自定义输入模板.

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.

我们的展望是,如果这是一项有价值的功能, 对于社区,可以创建第三方模块,该模块提供 单独的一组Bootstrap表单帮助程序模板,特定于给定的 Bootstrap版本,提供了比以前更好的用户体验 当前提供.

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.

这篇关于我可以忽略“不推荐使用Twitter引导程序"吗?我的代码中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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