- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
经过一些研究,包括阅读 Font Awesome 5 with Angular , documentation等我无法推进 Angular 5 App 和 Font-Awesome 5 (Pro) 之间的集成。
问题:图标不显示。
有关我当前场景的更多详细信息:
package.json:
(...)
"dependencies": {
"@angular/animations": "^5.2.4",
"@angular/common": "^5.2.4",
"@angular/compiler": "^5.2.4",
"@angular/core": "^5.2.4",
"@angular/forms": "^5.2.4",
"@angular/http": "^5.2.4",
"@angular/platform-browser": "^5.2.4",
"@angular/platform-browser-dynamic": "^5.2.4",
"@angular/router": "^5.2.4",
"@fortawesome/fontawesome": "^1.1.3",
"@fortawesome/fontawesome-pro-light": "^5.0.6",
"bootstrap": "^4.0.0",
"classlist.js": "^1.1.20150312",
"core-js": "^2.5.3",
"jquery": "^3.3.1",
"jquery-ui": "^1.12.1",
"popper.js": "^1.12.9",
"prismjs": "^1.11.0",
"rxjs": "^5.5.6",
"summernote": "^0.8.9",
"sweetalert2": "^7.11.0",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.20"
},
"devDependencies": {
"@angular/cli": "^1.7.0-rc.0",
"@angular/compiler-cli": "^5.2.4",
"@angular/language-service": "^5.2.4",
"@types/jasmine": "^2.8.6",
"@types/jasminewd2": "^2.0.3",
"@types/node": "^9.4.5",
"codelyzer": "^4.1.0",
"jasmine-core": "^2.99.1",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "^1.0.1",
"karma-coverage-istanbul-reporter": "^1.4.1",
"karma-jasmine": "^1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "^5.3.0",
"ts-node": "^4.1.0",
"tslint": "^5.9.1",
"typescript": "^2.7.1"
}
(...)
angular-cli.json
(...)
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/popper.js/dist/umd/popper.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/jquery-ui/ui/data.js",
"../node_modules/jquery-ui/ui/disable-selection.js",
"../node_modules/jquery-ui/ui/scroll-parent.js",
"../node_modules/jquery-ui/ui/widget.js",
"../node_modules/jquery-ui/ui/widgets/mouse.js",
"../node_modules/jquery-ui/ui/widgets/sortable.js",
"../node_modules/sweetalert2/dist/sweetalert2.min.js",
"../node_modules/summernote/dist/summernote.min.js",
"../node_modules/@fortawesome/fontawesome/index.js (tried with and without this file)"
], (...)
在我的研究过程中,我了解到我需要指定我需要使用什么(图标),如下所示:
import {faChevronLeft, faChevronRight} from '@fortawesome/fontawesome-free-solid';
import fontawesome from '@fortawesome/fontawesome';
然后我需要将这些图标传递给 fontawesome 对象:
fontawesome.library.add(faChevronLeft, faChevronRight);
最后我发现(在 font-awesome documentation 中我需要调用 i2svg 方法来负责让奇迹发生:
fontawesome.dom.i2svg();
文档说我必须调用不带参数的方法。但编译器将我指向另一个方向,我必须告知以下数据:
export interface DOM {
i2svg(params: { node: Node; callback: () => void }): void;
css(): string;
insertCss(): string;
}
到目前为止,我所取得的最大成果是由 font-awesome 在浏览器中生成的日志,并在此代码后包含以下信息“fontawesome.dom.i2svg()”:
fontawesome.dom.i2svg({ node: document.body, callback: callbacki2Svr });
function callbacki2Svr() { }
我已经尝试了很多(null 导致“Uncaught TypeError: Cannot read property 'querySelectorAll' of null”),现在我无法前进。有人有建议吗?
安装:
1) 按照 use node js 上的说明进行操作([TOKEN] 是我从购买中收到的 key ):
npm i --save @fortawesome/fontawesome
npm config set @fortawesome:registry https://npm.fontawesome.com/[TOKEN]
Created a .npmrc file in the root of my project with the following content:
@fortawesome:registry=https://npm.fontawesome.com/[TOKEN]
npm i --save @fortawesome/fontawesome-pro-light
2) 更新了 Angular-cli3) 使用 (ng b -aot) 重建应用程序4)启动项目。
提前谢谢您!
HTML 代码示例登录页面(无“i”标签)
<div class="login-page">
<div class="wrapper-login">
<img src="assets/image/logo/horizontal-bew.svg" />
<raptor-textbox #txtUser type="text" iconClass="fa fa-user-o" iconPosition="right" placeholder="Login"
[(value)]="userName" (onKeyUp)="updateUserName($event)" (onEnterPressed)="userKeyEnter()"></raptor-textbox>
<raptor-textbox #txtPwd type="password" iconClass="fa fa-key" iconPosition="right" placeholder="Senha"
[value]="pwd" (onKeyUp)="updatePwd($event)" (onEnterPressed)="pwdKeyEnter()"></raptor-textbox>
<raptor-button cssClass="btn btn-light btn-block" text="Entrar" (click)="authenticate()"></raptor-button>
<a [attr.href]="'#loginModal'" data-toggle="modal" [attr.data-target]="'#loginModal'">Forgot Password</a>
</div>
</div>
<raptor-modal title="Forgot Password"
icon="fa fa-envelope-o"
cssClass="fade"
classModal="modal-dialog modal-dialog-centered"
modalId="loginModal"
(onSavedClicked)="saveForm($event)"
(onCancelClicked)="cancelModal($event)">
<div class="row">
<div class="form-group col-12">
<label>Email</label>
<raptor-textbox type="email" typeValue="email" applyValidation="true" applyMask="true" icon="fa fa-envelope" iconPosition="right" placeholder="E-mail..."></raptor-textbox>
</div>
</div>
</raptor-modal>
Raptor 按钮(带有“i”标签)
<button type="button" [class]="cssClass" (click)="click()" [attr.data-target]="dataTarget" [attr.disabled]="isDisabled ?'' : null">
<i *ngIf="hasIcon()" class="{{ icon }}"></i><span>{{ text }}</span>
</button>
/**
* verify if icon was defined
* @hasIcon
*
*/
public hasIcon() {
return this.icon && this.icon.length > 0;
}
最佳答案
我们正在开发官方 Angular 组件(目前处于预发布状态)https://github.com/FortAwesome/angular-fontawesome
但是,@daniel-santana 告诉我们,这不可能集成到他们的大型应用程序中。
所以我能给你的最好建议是不要使用 SVG 和 JS 方法。它使用了 requestAnimationFrame 和 MutationObservers 等高级功能,但这些功能与 Angular 配合不佳。如果您无法重构您的应用程序以使用新的 SVG 格式(这是 Font Awesome 5 中的新格式),请坚持使用 Web Fonts 。版本 5 的网络字体的工作方式与版本 4 中的网络字体类似。升级到版本 5 将涉及更改任何已重命名的图标的名称。我们有详细docs here .
关于Angular 5 与 Font Awesome 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48758470/
将以下内容添加到我的键绑定(bind)中可以让我将 Sublime Text 3 中的字体大小重置为默认大小: { "keys": ["ctrl+0"], "command": "reset_font
我有一个如下所示的 css 字体系列(由于显示限制,我已经缩短了它,否则它比我在这里展示的要大得多)现在你能告诉我是否有办法将 url()content 转换为 .ttf 字体格式或其他标准字体格式吗
具体来说... and ...显示为双倍或四倍。 最佳答案 Customize Twitter Bootstrap here. Make sure to uncheck the default "
当包含 @font-face 和 src 以导入网络字体时,我注意到您可以传入 2 个可选值。我目前不这样做。 我有 2 种网络字体,Lato Regular 和 Lato Bold。 我应该在 @f
我正在本地主机上测试一个字体很棒的网站,它工作正常;但是当我将它上传到我的远程站点时,它不再显示字体了。我该如何解决?尝试了所有调试但没有成功。 网站在那里 www.sevotec.it/ordine
我开始使用 font-squirrel (http://www.fontsquirrel.com/tools/webfont-generator) 来快速使我的字体跨浏览器兼容,我只是想知道字体质量是
以前我复制了一个ttf文件到C:\Windows\Fonts,点击文件显示字体,然后点击[安装],一切正常。 当我现在执行此过程时,字体未安装在 C:\Windows\Fonts 中,而是安装在 C:
我注意到,在工作中,Google Web字体未出现在IE9和Firefox 6(Windows和Mac OS)上。所有文件都已加载,但字体从未渲染。在那些相同的浏览器上,它可以在家正常工作。 Chro
我正在学习 Swift UI 教程,我遇到了这个错误,而讲师没有。 .font 错误在第一个 Vstack 中仅出现一次,而第二次则没有问题。 import SwiftUI struct Conten
我知道使用@font-face 允许浏览器下载自定义字体并在网页中使用它,就像使用任何系统字体一样。 我想知道的是浏览器是对字体进行编码还是在不公开的情况下使用它? 谢谢 最佳答案 浏览器无法保护字体
使用基于@font-face 标记的标准fontsquirrel .. 字体呈现在较粗的一面。下面是一个屏幕截图,以几种不同的方式展示了字体。顶部是 photoshop 的渲染图,第二个是相同字体的
我必须在元素中使用花哨的字体,但我真的很想避免使用 sifr 和其他丑陋的替代品,所以我正在寻找@font-face。 但是,我真的很困惑几个博客/网站提供了关于它的可用性的不同观点。准备好了吗?目前
我几乎在我工作的所有项目中都使用 fontawesome。但这次我得到的图标显示为正方形。我还尝试了 stackoverflow 上列出的几乎所有解决方案,但似乎对我的情况没有任何效果。我猜是什么东西
好的,所以我正在尝试让 IE9 显示字体 Agenda。我像往常一样去了 fontsquirrel,它说 font bureau 不允许他们创建字体套件。然后我去了 codeandmore 并在那里制
Font Awesome 4.0是对 Font Awesome 从头开始的完全重写。主要的新功能之一是图标现在具有命名空间。除了命名空间之外,图标还使用基于一致性和可预测性的新命名约定。不幸的是,
我使用版本 3.2.9 (Media Mark) 的 SASS 并且我想使用我的自定义 font-family 的 3 个变体Source Sans Pro 字体(Light、Regular、Bold
在一些 css 文件中嵌入一些 base64 字体,但 CSP 阻止了这些:类似于 url("data:font/woff;base64,d09GRk9UVE...); 当前 CSP =“base-u
我怎样才能使 Font Awesome 图标像本页中那样大: http://fontawesome.io/icon/bath/ 我使用了 fa-5x 类,但它与页面示例中最大的图标不同。 下面是我使用
我有一个带有Bootsrap 4(SASS)和Font Awesome 5的MVC项目。我正在尝试使旋转的图标可以与Ajax加载面板一起使用,但是它不起作用。 Test Spin
似乎 font-awesome 支持自定义图标,并附有详细说明如何创建和提交您自己的图标,但该信息在他们的网站上不再可用。这是否意味着不再支持此功能并且您只能请求由 font-awesome 团队完成
我是一名优秀的程序员,十分优秀!