【问题标题】:Angular CLI project Bootstrap has-success or has-danger class not loadingAngular CLI 项目 Bootstrap has-success 或 has-danger 类未加载
【发布时间】:2018-03-07 01:47:33
【问题描述】:

我还有一个问题要问社区,这个问题很简单。作为之前的问题,我正在编写 Asim Hussain 先生的“Angular4 从理论到实践”一书,并遇到了 bootstrap .has-danger 和 .has-success 类不起作用的问题。我用

安装了引导程序
npm install bootstrap --save

在 .angular-cli.json 中添加了引导 css 的路径

"styles": [
      "../node_modules/bootstrap/dist/css/bootstrap.min.css",
      "styles.css"
   ],

一切似乎都运行良好,网格和表单样式加载良好,控制台中没有错误。当我在练习后实施验证时出现问题,表单字段边框没有变成应有的红色或绿色,这是我的代码

<!-- One of the fields from the form -->
 <div class="form-group"
    [ngClass]="{
        'has-danger': f.form.controls.email?.invalid && (f.form.controls.email?.dirty || f.form.controls.email.touched),
        'has-success': f.form.controls.email?.valid && (f.form.controls.email?.dirty || f.form.controls.email.touched)

    }">
        <label>Email</label>
        <input type="email"

               class="form-control"
                     name="email"
                     [(ngModel)]="model.email"
                     required
                     pattern="[^ @]*@[^ @]*">
    </div>

不确定为什么引导类没有将文本字段变为应有的红色或绿色,有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: angularjs-directive


    【解决方案1】:

    这个问题是 7 个月前的问题,但回答可能对其他人有所帮助。

    .has-danger 不再存在。 这个问题已经在这里问过了:

    has-danger no longer working on Bootstrap v4 beta?

    【讨论】:

    • 是的,我做了一些研究并认为这是问题所在,但仍然感谢您花时间回答。
    猜你喜欢
    • 2018-02-21
    • 2018-07-22
    • 2018-07-14
    • 2017-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-30
    相关资源
    最近更新 更多