how to send string data into a javascript?

天大地大妈咪最大 提交于 2020-01-05 14:17:46

问题


I am using v8 and i faced next problem - i have an application which running a javascript file ( i simply read it into a string and than execute with

Local<String> source = String::New(javascript); //javascript is string with js file
Local<Script> script = Script::Compile(source);
Local<Value> result = script->Run(); 

how can I send a string variable into this file?


回答1:


Put a placeholder in the script source, like STRING_HERE. Then, before creating the source object, find that placeholder in the string and replace it with the string value you want.



来源:https://stackoverflow.com/questions/5980483/how-to-send-string-data-into-a-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!