napi_escape_handle
napi_status napi_escape_handle(napi_env env,
napi_escapable_handle_scope scope,
napi_value escapee,
napi_value* result);
-
[in] env
:调用 API 的环境。¥
[in] env
: The environment that the API is invoked under. -
[in] scope
:napi_value
代表当前范围。¥
[in] scope
:napi_value
representing the current scope. -
[in] escapee
:napi_value
表示要转义的 JavaScriptObject
。¥
[in] escapee
:napi_value
representing the JavaScriptObject
to be escaped. -
[out] result
:napi_value
表示外部作用域中转义的Object
的句柄。¥
[out] result
:napi_value
representing the handle to the escapedObject
in the outer scope.
如果 API 成功,则返回 napi_ok
。
¥Returns napi_ok
if the API succeeded.
此 API 提升 JavaScript 对象的句柄,使其在外部作用域的生命周期内有效。每个作用域只能调用一次。如果多次调用,将返回错误。
¥This API promotes the handle to the JavaScript object so that it is valid for the lifetime of the outer scope. It can only be called once per scope. If it is called more than once an error will be returned.
即使存在挂起的 JavaScript 异常,也可以调用此 API。
¥This API can be called even if there is a pending JavaScript exception.