🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
如果插件需要使用到配置功能,我们需要在插件目录`根目录/addons/mydemo`创建一个`config.php`配置文件。 ## config.php 插件配置 `config.php`需要返回一个多维数组,例如: ``` <?php return [ [ //配置名称,该值在当前数组配置中确保唯一 'name' => 'yourname', //配置标题 'title' => '配置标题', 'type' => 'text', 'options' => [ '1' => '显示', '0' => '不显示' ], //配置值 'value' => '1', 'tip' => '字段填写帮助', ], [ 'name' => 'yourname2', 'title' => '配置标题2', 'type' => 'radio', //当配置1值为1时才显示,为其它值不显示 'visible' => 'yourname1=1', 'options' => [ '1' => '显示', '0' => '不显示' ], 'value' => '1', 'tip' => '字段填写帮助', ], [ 'name' => '__tips__', 'title' => '温馨提示', 'type' => 'string', 'value' => '该提示将出现的插件配置头部,通常用于提示和说明', 'tip' => '', ], ]; ``` ## 参数说明 |  名称 | 类型   | 说明 | | --- | --- | --- | | name   | string  | 配置名称,配置的唯一标识,仅支持英文、数字、下划线 | | title   | string  | 配置标题,用于显示在插件配置中的值 | | type | string | 类型,可用值:text/textarea/password/array/select/image/images/file/files/checkbox/radio| | visible | string | 动态可见条件,仅1.1.4+版本支持 | | options | array | 内容,当`type`为`checkbox/radio/select`值时的配置项 | | value | mixed | 配置值,用户输入或选择的值 | | tip | string | 验证获得焦点时的提示消息 | ## config.html 自定义配置页面 自动生成的配置有时候不能满足我们需求,可以在插件目录下创建一个`config.html` ,同时里面的字段要和`config.php`对应。 我们可以参考`application/admin/view/addons/config.html`的视图模板来复制到`插件目录/config.html`中来个性化我们的配置展示。