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

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

问题描述

我正在使用带有 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

我搜索了警告,只找到了这个 关于它的旧 SO 帖子github 上的问题.

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?

推荐答案

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

另一个原因是当前 Bootstrap 对 CSS 的要求类不能单独使用 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.

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

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