[comment]: # ({33a6b22e-2f868b63})
# 模块创建

[comment]: # ({/33a6b22e-2f868b63})

[comment]: # ({da5198e9-b100d64b})
### 描述

`object module.create(object/array modules)`

此方法允许安装新的前端模块。

::: noteclassic
此方法仅对*超级管理员*用户类型可用。
调用该方法的权限可以在用户角色设置中撤销。
更多信息请参见[User roles](/manual/web_interface/frontend_sections/users/user_roles)。
:::

::: noteimportant
模块文件必须手动解压到正确的子目录中，并与模块的`relative_path`属性相匹配。
:::

[comment]: # ({/da5198e9-b100d64b})

[comment]: # ({b5fc0458-a3899c85})
### 参数

`(object/array)` 要创建的模块。

该方法接受带有[模块](object#模块)的模块。

[comment]: # ({/b5fc0458-a3899c85})

[comment]: # ({ecf1e93b-b4af5197})
### 返回值

`(object)` 返回一个object，其中包含已安装模块的 ID，这些 ID 位于 `moduleids` 属性下。
返回的 ID 顺序与传入模块的顺序一致。

[comment]: # ({/ecf1e93b-b4af5197})

[comment]: # ({b41637d2-d5892b27})
### 示例

[comment]: # ({/b41637d2-d5892b27})

[comment]: # ({78517ea1-f4bbc4e4})
#### 安装模块

安装状态为“Enabled”的模块。

[执行请求](/manual/api#执行请求):


```json
{
    "jsonrpc": "2.0",
    "method": "module.create",
    "params": {
        "id": "example_module",
        "relative_path": "modules/example_module",
        "status": 1
    },
    "id": 1
}
```
响应：


```json
{
    "jsonrpc": "2.0",
    "result": {
        "moduleids": [
            "25"
        ]
    },
    "id": 1
}
```

[comment]: # ({/78517ea1-f4bbc4e4})

[comment]: # ({30745fe9-97287e12})
### 另请参阅

-   [模块](object#模块)
-   [Frontend modules](/manual/extensions/frontendmodules)

[comment]: # ({/30745fe9-97287e12})

[comment]: # ({c96370ba-174be480})
### 来源

CModule::create() 在 *ui/include/classes/api/services/CModule.php* 中。

[comment]: # ({/c96370ba-174be480})
