0

使用以下等效代码的新版本Nan:以下代码适用于 0.12.*,但不适用于 4.3.0 及更高版本。

//1)  
//This is my object_
Persistent<Object> object_;

Local<Object> obj = Nan::New<Object>();
NanAssignPersistent(object_, obj); //Don't know what to replace with here


//2)
NanDisposePersistent(object_); //Don't know what to replace with here 
4

1 回答 1

3

文档在这里nan展示了如何处理 Persistents 。查看Persistent 的测试也可能很有用。nan

例子:

Local<Object> obj;
Local<Object> obj2;

// Create a persistent
Nan::Persistent<v8::Object> persistent(obj);

// Get a local handle to the persisted object
v8::Local<v8::Object> orig_obj = Nan::New(persistent);

// Change the persistent reference
persistent.Reset(obj2);

// Dispose of the persistent
persistent.Reset();
于 2016-02-15T05:53:32.160 回答