我动态创建图标名称,有时会发生库中没有对应的图标。有什么方法可以捕获错误并使用默认图标名称?
问问题
221 次
1 回答
1
您可以使用findIconDefinition
以下方式查找图标名称:
// Set params with details of the icon you're looking up depending
// on what variant you're using.
let params = {
iconName: iconName,
prefix: prefix
// other entries as needed
};
if (!findIconDefinition(params)) {
// Use default icon here.
}
详细信息findIconDefinition
在https://fontawesome.com/how-to-use/javascript-api/methods/findicondefinition
于 2020-11-12T03:21:27.270 回答