napi_set_named_property


napi_status napi_set_named_property(napi_env env,
                                    napi_value object,
                                    const char* utf8Name,
                                    napi_value value); 
  • [in] env:调用 Node-API 时所处的环境。
  • [in] 对象:要在其上设置属性的对象。
  • [in] utf8Name:要设置的属性名称。
  • [in] value:属性值。

如果 API 成功,则返回 napi_ok

【Returns napi_ok if the API succeeded.】

此方法等同于调用 napi_set_property,并使用从传入的 utf8Name 字符串创建的 napi_value

【This method is equivalent to calling napi_set_property with a napi_value created from the string passed in as utf8Name.】