Update JSDemo.java
This commit is contained in:
parent
fecde68fe0
commit
1f3b757b63
|
|
@ -8,18 +8,18 @@ import com.whl.quickjs.wrapper.QuickJSContext;
|
||||||
|
|
||||||
public class JSDemo extends Spider {
|
public class JSDemo extends Spider {
|
||||||
|
|
||||||
private QuickJSContext jsContext;
|
private QuickJSContext ctx;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Context context, String extend) {
|
public void init(Context context, String extend) {
|
||||||
jsContext = QuickJSContext.create();
|
ctx = QuickJSContext.create();
|
||||||
jsContext.evaluate("var text = 'Hello QuickJS';");
|
ctx.evaluate("var text = 'Hello QuickJS';");
|
||||||
String text = jsContext.getGlobalObject().getString("text");
|
String text = ctx.getGlobalObject().getString("text");
|
||||||
SpiderDebug.log(text);
|
SpiderDebug.log(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
jsContext.destroy();
|
ctx.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue