resolve()
此函数是 Iconify Tools 中 IconSet 类的一部分。
函数 resolve() 用于检索 IconifyIcon 格式的图标数据。
用法
该函数具有以下参数:
- name,string 类型。图标名称。
- full,boolean 类型。可选参数。如果为 true,函数将返回完整的图标数据(FullIconifyIcon)。
函数返回 IconifyIcon(如果第二个参数为 true 则返回 FullIconifyIcon),出错时返回 null。
示例
example.ts
ts
import { IconSet } from '@iconify/tools';
const iconSet = new IconSet({
prefix: 'codicon',
icons: {
'add': {
body: '<g fill="currentColor"><path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"/></g>',
},
'debug-pause': {
body: '<g fill="currentColor"><path d="M4.5 3H6v10H4.5V3zm7 0v10H10V3h1.5z"/></g>',
hidden: true,
},
'triangle-left': {
body: '<g fill="currentColor"><path d="M10.44 2l.56.413v11.194l-.54.393L5 8.373v-.827L10.44 2z"/></g>',
},
},
aliases: {
'plus': {
parent: 'add',
},
'triangle-right': {
parent: 'triangle-left',
hFlip: true,
},
},
});
// Resolve icon (partial and full)
console.log(iconSet.resolve('debug-pause'));
console.log(iconSet.resolve('debug-pause', true));
// Resolve variation (partial and full)
console.log(iconSet.resolve('triangle-right'));
console.log(iconSet.resolve('triangle-right', true));
// Resolve alias (partial and full)
console.log(iconSet.resolve('plus'));
console.log(iconSet.resolve('plus', true));Results for "debug-pause":
json
{
"body": "<g fill=\"currentColor\"><path d=\"M4.5 3H6v10H4.5V3zm7 0v10H10V3h1.5z\"/></g>",
"hidden": true
}json
{
"left": 0,
"top": 0,
"width": 16,
"height": 16,
"rotate": 0,
"vFlip": false,
"hFlip": false,
"body": "<g fill=\"currentColor\"><path d=\"M4.5 3H6v10H4.5V3zm7 0v10H10V3h1.5z\"/></g>",
"hidden": true
}Results for "triangle-right":
json
{
"body": "<g fill=\"currentColor\"><path d=\"M10.44 2l.56.413v11.194l-.54.393L5 8.373v-.827L10.44 2z\"/></g>",
"hFlip": true
}json
{
"left": 0,
"top": 0,
"width": 16,
"height": 16,
"rotate": 0,
"vFlip": false,
"hFlip": true,
"body": "<g fill=\"currentColor\"><path d=\"M10.44 2l.56.413v11.194l-.54.393L5 8.373v-.827L10.44 2z\"/></g>"
}Results for "plus":
json
{
"body": "<g fill=\"currentColor\"><path d=\"M14 7v1H8v6H7V8H1V7h6V1h1v6h6z\"/></g>"
}json
{
"left": 0,
"top": 0,
"width": 16,
"height": 16,
"rotate": 0,
"vFlip": false,
"hFlip": false,
"body": "<g fill=\"currentColor\"><path d=\"M14 7v1H8v6H7V8H1V7h6V1h1v6h6z\"/></g>"
}