如何将字符串数据发送到javascript? [英] how to send string data into a javascript?

查看:138
本文介绍了如何将字符串数据发送到javascript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用v8和我面临下一个问题 - 我有一个应用程序运行一个javascript文件(我只是读它到一个字符串,而不是执行

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?

推荐答案

在脚本源中放置一个占位符,如 STRING_HERE 。然后,在创建源对象之前,在字符串中找到占位符,并将其替换为所需的字符串值。

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.

这篇关于如何将字符串数据发送到javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆