MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

Does hostobject support array from JavaScript #1440

Open yangzhongke opened 3 years ago

yangzhongke commented 3 years ago

My code in C#

[ComVisible(true)]
public class JavaScriptBridge
{
    public int Sum(int[] items)
    {
        return items.Sum();
    }
}

My Coe in JavaScript:

alert(await bridge.Sum([3, 5, 8]));

But it didn't work. image

I understand that I can work around this issue by using JSON.stringify() to convert an array in JavaScript to a plain string, and pass it to JavaScriptBridge. I just want to know whether there is a more graceful approach? Thanks.

AB#34069027

champnic commented 3 years ago

Yes this should be supported - I've added this as a bug on our backlog. Thanks!