Angular(点击)无法通过 CDN 与 Font Awesome 5 配合使用

标签 angular click icons font-awesome angular-fontawesome

我在一个小项目中使用 Angular CLI,并通过 CDN 使用 Fontawesome 5 来设置图标样式。

当我将 fontawesome“样式”类应用于某些按钮和链接时遇到了这个问题。

<input> , <a><i>当元素应用了 Fontawesome 类时,它们有不同的行为。

<div class="float-left clearSearchButton">
  <input type="button" (click)="clearFilter()" class="fas fa-eraser fa-xs"/>
  <input type="button" (click)="clearFilter()"/>
</div>

只有第二个输入正确执行了没有给定类的点击函数。

尝试交换元素内的点击和类属性,但也不起作用。 不过还没有尝试过通过 npm 获得 fontawesome ..

有人遇到过这个问题吗?

最佳答案

您确实可以将 <i> 包裹起来带有按钮的对象,如下所示:

<button class="fa-override faa-parent faa-slow animated-hover" ng-click="vm.showTimeSettings = !vm.showTimeSettings">
    <i class="fas fa-cog faa-spin text-primary"></i>
</button>

...我刚刚为按钮创建了一个新样式,使其没有边框/背景:

.fa-override {
  border-style: none;
  background-color: transparent;
  padding: 0;
}

这样的结果是这样的:

enter image description here

本期很好地描述了发生的情况和被破坏的情况:https://github.com/FortAwesome/Font-Awesome/issues/12055

关于Angular(点击)无法通过 CDN 与 Font Awesome 5 配合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49087017/

相关文章:

javascript - 执行 .click(function() 只有第一次点击

python - 单击网站上的按钮然后抓取网页

jquery - flotjs.navigationcontrol 中的 Bootstrap 图标

android - 制作动态启动器图标

angular - 不输入直接使用mat-datepicker

javascript - Angular 6 - 多级嵌套响应式表单重复输入

angular - Webpack 和 TypeScript 上的 SignalR : cannot find module './NodeHttpClient'

javascript - mouseup 事件停止 firefox 上的 click 事件

android - 为什么 Android Studio 在 res/drawable-v24 中创建 ic_launcher_foreground 而在 res/drawable 中创建 ic_launcher_background.xml?

Angular 4属性在构建时不存在于类型对象上