gpt4 book ai didi

Polymer 2 中的 Font Awesome

转载 作者:行者123 更新时间:2023-12-04 21:32:09 26 4
gpt4 key购买 nike

我想使用 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>

有谁知道为什么不显示图标?

最佳答案

首先,创建一个样式导入文件:(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>

现在您可以在您的应用程序中导入文件:
<link rel="import" href="../../lib/fontawesome-5.0.6/import.html">

请务必在要使用图标的任何位置包含导入:
<dom-module id="my-super-cool-polymer-app">
<template>
<style include="font-awesome">
<!-- etc -->

关于Polymer 2 中的 Font Awesome ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48591861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com