我正在尝试使用很棒的字体图标作为按钮

Am trying to use a font awesome icon as a button

我正在尝试使用字体真棒图标作为按钮来在我的网络应用程序中实现类似的功能,使用 bootstrap 4 和字体真棒

<button class="icon-button" onclick="actOnStory(event);"data-story-id="<%= story._id %>">
     <i class="far fa-heart"></i>
</button>

我当前的代码导致图标在按钮内部而不是按钮本身

不需要用 <button> 包裹 <i>,因为 onclick 事件也可以在图标上调用。就这样吧

<i class="far fa-heart" onclick="actOnStory(event);" data-story-id="<%= story._id %>"></i>