diff --git a/library/think/response/View.php b/library/think/response/View.php index e92cd052..224e3b60 100644 --- a/library/think/response/View.php +++ b/library/think/response/View.php @@ -38,7 +38,7 @@ class View extends Response /** * 视图变量赋值 - * @access protected + * @access public * @param array $vars 模板变量 * @return $this */ @@ -48,6 +48,21 @@ class View extends Response return $this; } + /** + * 获取视图变量 + * @access public + * @param string $name 模板变量 + * @return mixed + */ + public function getVars($name = null) + { + if(is_null($name)){ + return $this->vars; + }else{ + return isset($this->vars[$name]) ? $this->vars[$name] : null; + } + } + /** * 模板变量赋值 * @access public