我在我的项目中使用这个组件:yajra/laravel-datatables我有控制器:public function dataTable(Request $request) { if ($request->ajax()) { return Datatables::of($this->model->all()) ->addIndexColumn() ->editColumn('enable', function ($row) { if ($row->enable == 1) return '<span class="label font-weight-bold label-lg label-light-success label-inline">aktywny</span>'; else return '<span class="label font-weight-bold label-lg label-light-danger label-inline">nieaktywny</span>'; }) ->editColumn('name', function ($row) { return Str::limit($row->name, 80, '...'); }) ->addColumn('action', function ($row) { $btn = '<a href="' . route('product.edit', ['id' => $row->id]) . '" class="removeItem"><i class="far fa-edit"></i></a> '; $btn .= '<a href="' . route('product.destroy', ['id' => $row->id]) . '" class="removeItem"><i class="removeItem far fa-trash-alt"></i></a> '; return $btn; }) ->rawColumns(['action']) ->make(true); } }和 html: <table class="table table-bordered data-table "> <thead> <tr class="resources"> <th>ID</th> <th>Nazwa produktu</th> <th>Status</th> <th width="100px" class="text-center">Akcja</th> </tr> </thead> <tbody class="data-table-center"> </tbody> </table> </div> ] }); });在状态(启用)列中,我看到此 html 而不是最终字符串。好像一个刀片会严重取代这样的 html。我的结果:<span class="label font-weight-bold label-lg label-light-success label-inline">aktywny</span>预览: https: //ibb.co/6tXdH65我该如何解决?
目前暂无任何回答
- 0 回答
- 0 关注
- 86 浏览
添加回答
举报
0/150
提交
取消