我是V8的新手。我试图运行Hello示例表单这里。
但是,我在这一行中得到了编译错误:
v8::String source = v8::String::New("'Hello' + ', World'");error C2440: 'initializing' : cannot convert from 'v8::Local<v8::String>' to 'v8::String'
我为什么要犯这个错误?
发布于 2013-12-30 10:58:21
字符串类发生了更改。它没有新方法了;它有NewFrom*方法:
static Local< String > NewFromUtf8 (Isolate *isolate, const char *data, NewStringType type=kNormalString, int length=-1)
static Local< String > NewFromOneByte (Isolate *isolate, const uint8_t *data, NewStringType type=kNormalString, int length=-1)
static Local< String > NewFromTwoByte (Isolate *isolate, const uint16_t *data, NewStringType type=kNormalString, int length=-1)您可以浏览doxygen文档:1String.html#aa4b8c052f5108ca6350c45922602b9d4
可以这样创建字符串:
v8::Isolate* i = v8::Isolate::New();//create an isolate instance
//( if you already have one just get it: GetIsolate()
//=>http://bespin.cz/~ondras/html/classv8_1_1Context.html
v8::Local<v8::String> constant_name = v8::String::NewFromUtf8(i,"asd");
i->Dispose();https://stackoverflow.com/questions/20835320
复制相似问题