Javascript 如何在Electron.net中接收多个参数

Javascript 如何在Electron.net中接收多个参数,javascript,c#,electron,electron.net,Javascript,C#,Electron,Electron.net,我想接收带有多个参数的IPC.send消息。JavaScript如下所示: document.getElementById("btn-submit").addEventListener("click", () => { ipcRenderer.send("btn-submit", [document.getElementById("uid").nodeValue, document.getElementById("pw").nodeValue]);

我想接收带有多个参数的IPC.send消息。JavaScript如下所示:

document.getElementById("btn-submit").addEventListener("click", () => {
                ipcRenderer.send("btn-submit", [document.getElementById("uid").nodeValue, document.getElementById("pw").nodeValue]);
            });
当我尝试创建位于控制器内的侦听函数时,当我将args作为数组引用时,收到一个语法错误,如下所示:

Electron.IpcMain.On("btn-submit", async (args) =>
                {
                    MessageBoxOptions options = new MessageBoxOptions(String.Format("UID: {0} PW:{1}",args[0],args[1]))
                    {
                        Type = MessageBoxType.info,
                        Title = "Information",
                        Buttons = new string[] { "Yes", "No" }
                    };

                    var result = await Electron.Dialog.ShowMessageBoxAsync(options);
                });
如何在ipcMain侦听方法中接收从ipcRenderer.send方法传递的多个参数?

尽管(…)上的
会采取
操作
,当存在多个参数时,可以将
对象
强制转换为
列表
,这将解决语法问题:

Electron.IpcMain.On("btn-submit", async (args) =>
                {
                    var listArgs = (List<object>)args;
                    MessageBoxOptions options = new MessageBoxOptions(String.Format("UID: {0} PW:{1}",listArgs[0],listArgs[1]))
                    {
                        Type = MessageBoxType.info,
                        Title = "Information",
                        Buttons = new string[] { "Yes", "No" }
                    };

                    var result = await Electron.Dialog.ShowMessageBoxAsync(options);
                });
Electron.IpcMain.On(“btn提交”,异步(args)=>
{
var listArgs=(List)args;
MessageBoxOptions=newmessageboxoptions(String.Format(“UID:{0}PW:{1}”、listArgs[0]、listArgs[1]))
{
Type=MessageBoxType.info,
Title=“信息”,
按钮=新字符串[]{“是”、“否”}
};
var result=wait Electron.Dialog.ShowMessageBoxAsync(选项);
});
尽管(…)上的
.On
采取了
操作
,但当存在多个参数时,您可以将
对象
强制转换为
列表
,这将解决语法问题:

Electron.IpcMain.On("btn-submit", async (args) =>
                {
                    var listArgs = (List<object>)args;
                    MessageBoxOptions options = new MessageBoxOptions(String.Format("UID: {0} PW:{1}",listArgs[0],listArgs[1]))
                    {
                        Type = MessageBoxType.info,
                        Title = "Information",
                        Buttons = new string[] { "Yes", "No" }
                    };

                    var result = await Electron.Dialog.ShowMessageBoxAsync(options);
                });
Electron.IpcMain.On(“btn提交”,异步(args)=>
{
var listArgs=(List)args;
MessageBoxOptions=newmessageboxoptions(String.Format(“UID:{0}PW:{1}”、listArgs[0]、listArgs[1]))
{
Type=MessageBoxType.info,
Title=“信息”,
按钮=新字符串[]{“是”、“否”}
};
var result=wait Electron.Dialog.ShowMessageBoxAsync(选项);
});