Home > SYS_Dialog > showSelectDialog
SYS_Dialog.showSelectDialog() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Show a select dialog
Signature
function showSelectDialog(
options: Array<string> | Array<{ value: string; displayContent: string }>,
beforeContent?: string,
afterContent?: string,
title?: string,
defaultOption?: string,
multiple?: false,
callbackFn?: (value: string) => void | Promise<void>,
): void;2
3
4
5
6
7
8
9
Parameters
Parameter | Type | Description |
|---|---|---|
options | Array<string> | Array<{ value: string; displayContent: string }> | Option list, which can be an array of strings or an array of objects. When |
beforeContent | string | (Optional) Text above the select box |
afterContent | string | (Optional) Text below the select box |
title | string | (Optional) Select box title |
defaultOption | string | (Optional) Default option, using the option value as the matching parameter. If the |
multiple | false | (Optional) Whether multiple selection is supported. By default, it is a single-select box |
callbackFn | (value: string) => void | Promise<void> | (Optional) Callback function |
Returns
void
The value selected by the user, corresponding to the value field in the passed-in options
Example
// 1. 单选:对象数组让 value 与展示文案分离,默认选中 TOP
eda.sys_Dialog.showSelectDialog(
[
{ value: 'TOP', displayContent: '顶层' },
{ value: 'BOTTOM', displayContent: '底层' }
],
'请选择丝印放置的层', // 选择框上方文字
'设置会应用到全部丝印', // 选择框下方文字
'丝印层设置', // 窗口标题
'TOP', // 默认选项(匹配选项的 value)
false, // 单选
(value) => {
console.log('单选结果:', value);
}
);
// 2. 多选:字符串数组作选项,multiple 传 true,默认选中两项
eda.sys_Dialog.showSelectDialog(
['DRC', 'BOM', 'Gerber'],
'请选择需要导出的内容', // 多选框上方文字
'', // 多选框下方文字
'导出设置', // 窗口标题
['DRC', 'BOM'], // 默认选项数组
true, // 多选
(values) => {
console.log('多选结果:', values);
}
);
// 3. 两个窗口已弹出;回调需用户点击确认后才会触发
console.log('已弹出选择窗口(单选 + 多选)');2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31