所以,我明白了:
void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) {
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
int last_number = info[0]->NumberValue(context).FromJust();
info.GetReturnValue().Set(Nan::New<(fib(last_number)));
}
这里使用https://github.com/nodejs/nan我需要从这个函数返回一个字符串值。函数 fib 返回一个 int 值。任何将 int 转换为字符串的方法都会给我不同的错误。