Skip to content

I cannot assign the c# Array or List to javascript, can you provide the Class to help set Array value to JS #375

Closed

Description

When I assign the c# Array or List to JS, when I use the forEach in JS, it will report error, I think we need a class corresponding to JS array to help us easily pass arrays to JS.
Now I set the array to JS like this

public object CreateNativeArray<T>(List<T> data) {
            SetValue("__$_convert_array_data__", new JSIList<T>(data));
            var obj = Evaluate("var array = [];__$_convert_array_data__.forEach(t=>{array.push(t);});array;");
            
            return obj;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions