我试图将传递给我的C++插件的参数转换为数组,但遇到标题错误。这是我的代码:
#include "node.h"
#include "node_buffer.h"
#include "v8.h"
using namespace v8;
using namespace std;
namespace water{
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Object;
using v8::String;
using v8::Number;
using v8::Value;
using v8::Array;
void water(const FunctionCallbackInfo<Value> &args)
{
if(args[0]->IsArray())
{
Local<Array> a = Array::Cast(*args[0]);
Local<Array> b = Array::Cast(*args[1]);
}
args.GetReturnValue().Set(20);
}
}
这是我的错误no suitable constructor exists to convert from “v8::Array *” to “v8::Local<v8::Array>”
换句话说,我正在寻找使用node-gyp将数组从NodeJs程序传递给我的方法的方法,但我似乎做不到。
最佳答案
读the documentation,我认为应该是
Local<Array> a = args[0].As<Array>();
关于c++ - 没有合适的构造函数可从 “v8::Array *”转换为 “v8::Local<v8::Array>”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63345279/