多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
![](https://img.kancloud.cn/a0/c8/a0c88d89c68247a680976fd2d841020f_621x747.png) ## 获取构建器实例 1. `ViewBuilder`中获取 ```php $viewBuilder = $this->viewBuilder; $formInstance = $viewBuilder->lists; ``` 2. `instance()`自身方法 ```php $formBuilder= ListBuilder::instance(); ``` 3. `new`关键词 ```php $formBuilder= new ListBuilder([ 'id' => '__admin_list', ]); ``` ## 示例 ~~~ /** * @return string * @throws \builder\base\InvalidInstanceException * @throws \builder\base\NotFoundParamsException */ public function actionDetail() { $viewBuilder = $this->viewBuilder; $viewBuilder->setPartial(); $lists = $viewBuilder->lists; $lists->setTitle('详情构建器') ->setListRows([ [ '班级' => $this->listRows->item('二班')->thAttribute(['width' => 90]), '班主任' => $this->listRows->item('李阳')->thAttribute(['width' => 90]), '联系方式' => $this->listRows->item('12225478878')->thAttribute(['width' => 90]), ], [ '用户名' => $this->listRows->item('杨慧磊'), '积分' => $this->listRows->item(500), '状态' => $this->listRows->item(H5::badge('成功')), ], '手机号' => $this->listRows->item(function () { return '15030321254'; })->tdAttribute(['colspan' => 5]), '订单号' => $this->listRows->item('N01878016587493544427')->tdAttribute(['colspan' => 5]), '平台' => $this->listRows->item('淘宝')->tdAttribute(['colspan' => 5]), '店铺' => $this->listRows->item('Wd028,爱吃鱼')->tdAttribute(['colspan' => 5]), '省' => $this->listRows->item('河南省')->tdAttribute(['colspan' => 5]), '市' => $this->listRows->item('郑州市')->tdAttribute(['colspan' => 5]), '区(县)' => $this->listRows->item('金水区')->tdAttribute(['colspan' => 5]), '详细地址' => $this->listRows->item('国贸大厦102')->tdAttribute(['colspan' => 5]), '商品信息' => $this->listRows->item('闪迪512g/1700 CFE卡')->tdAttribute(['colspan' => 5]), '员工' => $this->listRows->item('李四')->tdAttribute(['colspan' => 5]), '订单金额' => $this->listRows->item('100.00')->tdAttribute(['colspan' => 5]), '收益' => $this->listRows->item('20.00')->tdAttribute(['colspan' => 5]), '提成' => $this->listRows->item('5.00')->tdAttribute(['colspan' => 5]), '注册时间' => $this->listRows->item('2023/03/02 02:00')->tdAttribute(['colspan' => 5]), ]); return $viewBuilder->render(); } ~~~