Appearance
Class: Resource
资源管理和加载
默认提供了几个常用的加载器
ts
Resource.load('photo.png');
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new Resource()
Properties
listGroup
• listGroup: string
[] | [string
, string
] = []
Defined in
src/core/resource/Resource.ts:124
cache
▪ Static
cache: Object
= {}
所有缓存资源
Index signature
▪ [props: string
]: IRes
Defined in
src/core/resource/Resource.ts:47
loader
▪ Static
loader: LoaderType
= {}
所有加载器
Defined in
src/core/resource/Resource.ts:42
nameCache
▪ Static
nameCache: Object
= {}
资源别名缓存
Index signature
▪ [props: string
]: string
Defined in
src/core/resource/Resource.ts:52
Methods
get
▸ Static
get(name
): IRes
根据配置的名称获取资源
Parameters
Name | Type |
---|---|
name | string |
Returns
Defined in
src/core/resource/Resource.ts:102
getLoader
▸ Static
getLoader(type
): ILoader
获取加载器
Parameters
Name | Type | Description |
---|---|---|
type | string | 根据类型获取加载器 |
Returns
Defined in
src/core/resource/Resource.ts:143
load
▸ Static
load(source
, options?
): Promise
<IRes
>
加载资源
Parameters
Name | Type | Description |
---|---|---|
source | string | 资源路径 |
options? | LoadOptions | 配置 |
Returns
Promise
<IRes
>
Defined in
src/core/resource/Resource.ts:69
loadGroup
▸ Static
loadGroup(list
, worker?
): EventEmitter
<ValueOf
<{ COMPLATE
: "complate"
= 'complate'; LOADED
: "loaded"
= 'loaded' }>, any
>
加载一组资源
Parameters
Name | Type | Default value | Description |
---|---|---|---|
list | LoadResListConfig | undefined | 要加载的资源列表 |
worker | number | 1 | 最大同时加载数量,最小为1 |
Returns
EventEmitter
<ValueOf
<{ COMPLATE
: "complate"
= 'complate'; LOADED
: "loaded"
= 'loaded' }>, any
>
Defined in
src/core/resource/Resource.ts:131
set
▸ Static
set(name
, url
): boolean
配置资源别名
Parameters
Name | Type | Description |
---|---|---|
name | string | 别名 |
url | string | 资源url |
Returns
boolean
Defined in
src/core/resource/Resource.ts:115
setLoader
▸ Static
setLoader(type
, loader
): void
添加/修改一个loader加载器
Parameters
Name | Type | Description |
---|---|---|
type | string | 类型 |
loader | ILoader | 加载器 |
Returns
void