view->fetch(); } // 生成条码 public function build() { $text = $this->request->get('text', '1234567890'); $type = $this->request->get('type', 'C128'); $foreground = $this->request->get('foreground', "#000000"); $width = $this->request->get('width', 2); $height = $this->request->get('height', 30); $params = [ 'text' => $text, 'type' => $type, 'foreground' => $foreground, 'width' => $width, 'height' => $height, ]; $barcode = \addons\barcode\library\Service::barcode($params); // 直接显示条码 $response = Response::create()->header("Content-Type", "image/png"); header('Content-Type: image/png'); $response->content($barcode); return $response; } }