twitter-bootstrap has-danger 不再适用于 Bootstrap v4 测试版?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46179078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
has-danger no longer working on Bootstrap v4 beta?
提问by I'll-Be-Back
According to the Bootstrap migration guide:
Renamed .has-error to .has-danger.
将 .has-error 重命名为 .has-danger。
However, that doesn't seem to work. Border and text has not been coloured.
但是,这似乎不起作用。边框和文本未着色。
For example:
例如:
<div class="form-group has-danger">
<label class="form-control-label" for="inputDanger1">Input with danger</label>
<input type="text" class="form-control form-control-danger" id="inputDanger1">
<div class="form-control-feedback">Sorry, that username's taken. Try another?</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
Demo:
演示:
采纳答案by Zim
Being that Bootstrap 4 is still in Beta, much of the migration documentation is not in syncwith actual releases. Validation has changed in beta, and has-dangerno longer exists.
由于 Bootstrap 4 仍处于 Beta 阶段,大部分迁移文档与实际版本不同步。验证测试版已经改变,并且has-danger不再存在。
回答by I'll-Be-Back
Managed to get it to work. @ZimSystem is correct about this.
设法让它工作。@ZimSystem 对此是正确的。
.has-dangerexist in Alpha version but it was removed in Bootstrap v4 Beta. You will need to use is-invalidselector in the input and also include class="invalid-feedback"for error message.
.has-danger存在于 Alpha 版本中,但在 Bootstrap v4 Beta 中被删除。您将需要is-invalid在输入中使用选择器,还需要包含class="invalid-feedback"错误消息。
Here is example:
这是示例:
<div class="form-group has-danger">
<label class="form-control-label">Username</label>
<input type="text" class="form-control is-invalid">
<div class="invalid-feedback">Sorry, that username's taken. Try another?</div>
</div>
回答by Ashley Brown
It would appear that the betaversion doesn't have the .has-*classes.
As a work around, use the alpha-6 version
这样看来,在公测版本没有的.has-*类。作为解决方法,请使用 alpha-6 版本
https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css
https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css
Updated fiddle with new CDN.
使用新的 CDN 更新了小提琴。

