没有合适的构造函数可从“ v8 :: Array *”转换为“ v8 :: Local <v8 :: Array>”

问题描述

我试图将传递给我的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>();

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...