diff --git a/library/think/Controller.php b/library/think/Controller.php index 06649a03..5e34f699 100644 --- a/library/think/Controller.php +++ b/library/think/Controller.php @@ -92,6 +92,19 @@ class Controller return $this->view->fetch($template, $vars, $config); } + /** + * 加载模板和页面输出 可以返回输出内容 + * @access public + * @param string $template 模板文件名 + * @param array $vars 模板输出变量 + * @param array $config 模板参数 + * @return mixed + */ + public function display($template = '', $vars = [], $config = []) + { + return $this->view->fetch($template, $vars, $config); + } + /** * 渲染内容输出 * @access public diff --git a/library/think/View.php b/library/think/View.php index 7489b6a9..f1135ae5 100644 --- a/library/think/View.php +++ b/library/think/View.php @@ -186,6 +186,10 @@ class View $replace = $this->config['parse_str']; $content = str_replace(array_keys($replace), array_values($replace), $content); } + if (!Config::get('response_auto_output')) { + // 自动响应输出 + return Response::send($content, Response::type()); + } return $content; }