# 更改单个图标实例

**URL:** https://meta.discourse.org/t/change-single-instance-of-icon/336356
**Category:** Feature
**Created:** [2024年十一月15日 15:31 UTC](https://meta.discourse.org/t/change-single-instance-of-icon/336356 "2024-11-15T15:31:56Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2024年十一月19日 21:37 UTC](https://meta.discourse.org/t/change-single-instance-of-icon/336356/8 "2024-11-19T21:37:43Z")

</div>

我们默认在此处使用“滑块”图标（这也是 Discourse 默认情况下唯一使用此图标的地方）——因此在这种情况下使用 `replaceIcon()` 是安全的

![image](https://global.discourse-cdn.com/meta/original/4X/e/b/c/ebc46612145eb023c6a2748adb8ded0dc191bdc5.png)

由于我们没有替换单个图标的 API，因此今天支持此功能的最佳方法是评估添加新别名的请求，这些别名将相似的用例分组。

例如，我们使用 `d-liked` 作为 `heart` 的别名，因此可以针对 `d-liked` 使用 `replaceIcon()` 来更改它在“喜欢”上下文中的显示，而不是替换应用程序中所有出现的“心形”图标。

> <https://github.com/discourse/discourse/blob/7d8974d02f7360b324b446868463e950fe92883f/app/assets/javascripts/discourse-common/addon/lib/icon-library.js>

不过，能够替换任何单个出现的情况会很好，这在主题中并不罕见——希望有一天我们能有相应的 API。

---

_[View the full topic](https://meta.discourse.org/t/change-single-instance-of-icon/336356)._
