C# Jint 将值设置为 javascript 变量
C# Jint Set value to javascript variable
需要给javascript变量赋值
在此示例中需要 return 值。
1° 首先注册一个简单的函数
Engine js = new Engine();
js.SetValue("get_s_width",new Action<int>(get_s_width));
public void get_s_width(int i)
{
js.Execute("function test() { return 100; } test();");
}
在这种情况下,我尝试 return 来自 C# 函数的值
但在执行方法后,在屏幕上我看到 "null" 值
怎么做?
有人有想法吗?
您需要调用 engine.GetCompletionValue()
来检索最新的评估语句结果。
需要给javascript变量赋值
在此示例中需要 return 值。
1° 首先注册一个简单的函数
Engine js = new Engine();
js.SetValue("get_s_width",new Action<int>(get_s_width));
public void get_s_width(int i)
{
js.Execute("function test() { return 100; } test();");
}
在这种情况下,我尝试 return 来自 C# 函数的值 但在执行方法后,在屏幕上我看到 "null" 值 怎么做?
有人有想法吗?
您需要调用 engine.GetCompletionValue()
来检索最新的评估语句结果。