【问题标题】:Can I ignore the "twitter bootstrap is deprecated" warnings in my code?我可以忽略代码中的“twitter bootstrap is deprecated”警告吗?
【发布时间】:2015-05-26 07:38:28
【问题描述】:

我正在使用带有 twitter 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(""){

    @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

我搜索了警告,只找到了这个old SO post about it 和一个issue on github

SO 帖子提到编写他自己的模板助手,但由于我自己的工作,我认为还没有必要编写一个。那么我是否仍然可以使用我的并忽略警告,或者我以后会在我的生产系统或其他任何地方遇到麻烦?此外,如果警告没有后果,有没有办法隐藏它们?

【问题讨论】:

    标签: twitter-bootstrap playframework deprecated playframework-2.3


    【解决方案1】:

    Play 2.3 migration guide 中有一个部分旨在解释该问题。它说:

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

    这有几个原因,一个是我们发现 Bootstrap 在版本之间变化太剧烈而且太频繁, 这样 Play 提供的任何内置支持都会很快过时 并且与当前的 Bootstrap 版本不兼容。

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

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

    即使现在有效,将来也可能出现问题。如果我是你,我会为编写自定义解决方案而努力。只有这样,您才能确保在项目中升级框架后一切正常。

    【讨论】:

    • 我必须手动更新播放框架,对吗?不会自动更新到较新的版本?
    • 是的。我的意思是手动升级。但在您的产品维护期间可能会出现这种情况。
    • 好的,然后会考虑编写我自己的模板助手以确保。谢谢!
    【解决方案2】:

    现在,Play-Bootstrap 支持 Bootstrap 3 和 Bootstrap 4 以及 Play 2.4 和 Play 2.5。

    SNAPSHOT 构建不能直接加载,你必须这样做

    resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
    libraryDependencies ++= Seq(
      "com.adrianhurt" %% "play-bootstrap" % "1.1-P25-B3-SNAPSHOT"
    )
    

    (来源:https://github.com/adrianhurt/play-bootstrap/blob/master/play25-bootstrap3/sample/build.sbt

    【讨论】:

      猜你喜欢
      • 2018-07-21
      • 1970-01-01
      • 2020-09-10
      • 2014-11-21
      • 1970-01-01
      • 2011-03-27
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多