c#执行js

using (var js = new JavaScriptEngineSwitcher.ChakraCore.ChakraCoreJsEngine())
{
    js.EmbedHostObject("console", new { log = new Action<object>(p => Console.WriteLine(p)) });
    js.Execute("function test(a){return console.log(a++),a}");
    Console.WriteLine(js.CallFunction("test", 9));
}

猜你喜欢

转载自blog.csdn.net/slwsss/article/details/101109192