javascript - 是否可以将字体真棒图标添加到 whiwheel.js 段
问题描述
我正在使用Winwheel.js
库来创建一个轮子。现在我想改变轮段的样式。我想将FontAwesome
图标添加到带有文本的段中。可能吗?
我试过这样做,theWheel.segments[0].text="<span class='fas fa-viruses'> prize 1 </span>"
但没有奏效
<html>
<head>
<title>Code Wheel</title>
<script src='Winwheel.js'></script>
</head>
<body>
<canvas id='canvas' width='880' height='300'>
Canvas not supported, use another browser.
</canvas>
<script>
let theWheel = new Winwheel({
'numSegments' : 8, // Number of segments
'outerRadius' : 212, // The size of the wheel.
'centerX' : 217, // Used to position on the background correctly.
'centerY' : 219,
'textFontSize' : 28, // Font size.
'segments' : // Definition of all the segments.
[
{'fillStyle' : '#eae56f', 'text' : 'Prize 1'},
{'fillStyle' : '#89f26e', 'text' : 'Prize 2'},
{'fillStyle' : '#7de6ef', 'text' : 'Prize 3'},
{'fillStyle' : '#e7706f', 'text' : 'Prize 4'},
{'fillStyle' : '#eae56f', 'text' : 'Prize 5'},
{'fillStyle' : '#89f26e', 'text' : 'Prize 6'},
{'fillStyle' : '#7de6ef', 'text' : 'Prize 7'},
{'fillStyle' : '#e7706f', 'text' : 'Prize 8'}
],
'animation' : // Definition of the animation
{
'type' : 'spinToStop',
'duration' : 5,
'spins' : 8,
'callbackFinished' : alertPrize
}
});
// Called when the animation has finished.
function alertPrize(indicatedSegment)
{
// Do basic alert of the segment text.
alert("You have won " + indicatedSegment.text);
}
</script>
</body>
</html>
解决方案
推荐阅读
- flutter - Flutter/Dart/Firestore:如何创建子集合并将数据添加到 Firestore?
- android - 使用 Kotlin 中的导体库进行退出确认
- python - 按钮形成一个 tkinter 窗口,出现在另一个 tkinter 窗口上
- http2 - Deno 1.9 原生网络服务器 API 和方法?
- object - Odoo 12 - 创建对字段的依赖
- python - SQLAlchemy 正确处理死锁
- javascript - 我正在尝试将我的几何图形转换为 GeoJSON 格式,以便可以将其导入地理服务器。我收到以下错误
- ruby - 使用 Nokogiri xpath 解析时未插入 Ruby 环境变量
- python - 将对象数组中的元素从 int 转换为 float python numpy
- laravel - 如何在 Laravel Fortify 中进行身份验证后运行自定义代码?