当前位置: 首页 > 文档资料 > FIS3 中文文档 >

Config

优质
小牛编辑
121浏览
2023-12-01

fis.config. Config

new Config(initialOpitionsopt)

配置类。

Parameters:
NameTypeAttributesDescription
initialOpitionsObject<optional>

初始配置。

Source:
Example
var Config = fis.confilg.Config;
var config = new Config({
  a: 1
});
console.log(config.get('a')); // => 1
config.set('b.c', 2);
console.log(config.get('b')); // => {c: 2}

Methods

del(path)

删除指定路径的配置。

Parameters:
NameTypeDescription
pathString

配置项路径。

Source:

get()

通过路径获取配置值。

Source:

getMatches()

获取所有 matches 表。

Source:

getSortedMatches()

获取根据 weight 排序后的 matches 表。

Source:

hook(name, settings)

挂载 hook 插件

Parameters:
NameTypeDescription
namestring

插件名称

settingsObject

插件配置项

Source:
Example
fis.config.hook('module');

match(pattern, properties, weightopt)

添加文件属性。

Parameters:
NameTypeAttributesDescription
patternGlob | RegExp | String

匹配文件路径规则。

propertiesObject

属性对象。

weightBoolean | int<optional>

规则的权重,数字越大优先级越高。

Source:
Example
fis.config.match('*.js', {
  release: 'static/$0'
});

media(group) → {Config}

分组配置项。

Parameters:
NameTypeDescription
groupString

组名

Source:
Returns:

返回一个新的 Config 对象,用来分割配置项。

Type
Config

merge(target)

将目标配置项合并到当前配置中,类似于 jQuery.extend.

Parameters:
NameTypeDescription
targetObject

其他配置对象

Source:

set(path, value)

通过路径设置配置项。

注意:当设置路径时,如果目标路径已经存在,则会被覆盖。如果是多级路径,同时上级目录存在且值不为对象,则会报错。

如:

fis.config.set('a', 'sting');
// 如果这样设置会报错。
fis.config.set('a.subpath', 2);
Parameters:
NameTypeDescription
pathString

配置项路径。

valueMixed

Source:
Example
fis.config.set('xxxx', 1);

unhook()

取消 hook 插件

Source: