Home > LIB_Symbol > search
LIB_Symbol.search() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
搜索符号
签名
typescript
function search(
key: string,
libraryUuid?: string,
classification?: ILIB_ClassificationIndex | Array<string>,
symbolType?: ELIB_SymbolType,
itemsOfPage?: number,
page?: number,
): Promise<Array<ILIB_SymbolSearchItem>>;1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
参数名
参数 | 类型 | 描述 |
|---|---|---|
key | string | 搜索关键字 |
libraryUuid | string | (可选) 库 UUID,默认为系统库,可以使用 LIB_LibrariesList 内的接口获取 |
classification | ILIB_ClassificationIndex | Array<string> | (可选) 分类,默认为全部 |
symbolType | (可选) 符号类型,默认为全部 | |
itemsOfPage | number | (可选) 一页搜索结果的数量 |
page | number | (可选) 页数 |
返回值
Promise<Array<ILIB_SymbolSearchItem>>
搜索到的符号属性列表
示例
javascript
// 1. 尝试按关键字搜索(当前版本非空关键字会抛错,如实展示)
try {
const keywordResults = await eda.lib_Symbol.search('0402');
console.log('关键字搜索返回', keywordResults.length, '条');
}
catch (e) {
// 剥掉错误类型前缀;注意:正则写法尾部会产生星号+斜杠序列,会闭掉 tsdoc 注释,故用 split
console.log('关键字搜索当前版本抛错:', String(e.message).split('Error: ').pop());
}
// 2. 改用空关键字列出系统库符号,每页 5 条
const results = await eda.lib_Symbol.search('', undefined, [], undefined, 5, 1);
// 3. 输出搜索结果(需要过滤时可按 item.name 自行筛选)
console.log('count:', results.length);
results.forEach((item, i) => {
console.log(`[${i}] name:`, item.name, 'uuid:', item.uuid, 'libraryUuid:', item.libraryUuid);
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18