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_valuerepresenting the current scope. -
[in] escapee:napi_value表示要转义的 JavaScriptObject。¥
[in] escapee:napi_valuerepresenting the JavaScriptObjectto be escaped. -
[out] result:napi_value表示外部作用域中转义的Object的句柄。¥
[out] result:napi_valuerepresenting the handle to the escapedObjectin 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.