创建一个Admin
类 , 实现configMenu
方法 , 其他页面类继承Admin
类即可
#project\app\admin\controller\Admin.php
namespace app\admin\controller;
use easyadmin\app\libs\Menu;
use easyadmin\app\libs\MenuItem;
class Admin extends \easyadmin\controller\Admin
{
public function configMenu(Menu $menu)
{
$menu->setItems([
MenuItem::addItem('默认展开', 'http://www.baidu.com', ['class' => 'testclass'])
->setChildren([
MenuItem::addItem('选项一', 'http://www.wansh.cc'),
MenuItem::addItem('选项二', 'lists')
]),
MenuItem::addItem('查看详情', 'show', [
'params' => [
'id' => 7
]
]),
MenuItem::addItem('默认收起', 'javascript:')
->setChildren([
MenuItem::addItem('选项一', 'javascript:'),
MenuItem::addItem('选项二', 'show', [
'params' => [
'id' => 5
]
])
])
]);
// $menu->setTemplate('test:test1');
}
}