Skip to content

defaultIconCustomisations

此常量属于 Iconify Utils 包

常量 defaultIconCustomisations 用于提供默认的 FullIconifyIconCustomisations 值。

它由两部分合并而成:

defaultIconSizeCustomisations

常量 defaultIconSizeCustomisations 表示尺寸自定义项:widthheight

jsconst defaultIconSizeCustomisations = {
   width: null,
   height: null,
};

defaultIconTransformations

常量 defaultIconTransformations 表示变换:

jsconst defaultIconTransformations = {
   rotate: 0,
   vFlip: false,
   hFlip: false,
};

变换的默认值与 IconifyIcon 类型共享。

用法

example.ts
tsimport { defaultIconCustomisations, mergeCustomisations } from '@iconify/utils';

// Add horizontal flip and custom height
const fullCustomisations = {
   ...defaultIconCustomisations,
   hFlip: true,
   height: 24,
};

// Add horizontal flip again, but merge it properly using mergeCustomisations(), resulting in hFlip = false
const mergedCustomisations = mergeCustomisations(fullCustomisations, {
   hFlip: true,
});

通常它与 mergeCustomisations() 函数一起使用。

它也用于只需要部分自定义项的函数中,例如 iconToSVG(),但其内部实际上使用的是完整自定义项。