Amp*_*aro 5 font-awesome polymer-2.x
我想使用fontawesome图标。我有以下Web组件,但未显示图标:
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
<dom-module id="mi-icono">
<template>
<i class="fas fa-address-card"></i>
<i class="fas fa-trash-alt"></i>
</template>
<script>
/**
* @customElement
* @polymer
*/
class MiIcono extends Polymer.Element {
static get is() { return 'mi-icono'; }
static get properties() {
return {};
}
}
window.customElements.define(MiIcono.is, MiIcono);
</script>
</dom-module>
Run Code Online (Sandbox Code Playgroud)
谁知道为什么不显示图标?
小智 1
首先,创建一个样式导入文件:(import.html)
<link rel="import" href="../../bower_components/polymer/polymer-element.html">
<link rel="stylesheet" href="css/fa-regular.min.css">
<dom-module id="font-awesome">
<template>
<style>
<!-- TODO: Paste contents of fontawesome-all.css here! -->
<!-- TODO: Update paths in pasted content to match directory structure -->
<!-- Would be awesome to use @import here but it doesn't work? -->
</style>
</template>
</dom-module>
Run Code Online (Sandbox Code Playgroud)
现在您可以在应用程序中导入该文件:
<link rel="import" href="../../lib/fontawesome-5.0.6/import.html">
Run Code Online (Sandbox Code Playgroud)
请务必在要使用图标的任何位置包含导入:
<dom-module id="my-super-cool-polymer-app">
<template>
<style include="font-awesome">
<!-- etc -->
Run Code Online (Sandbox Code Playgroud)