这是我的控制员之一:
class MediaController extends BaseController {
private $js_files = array(), $css_files = array();
/** Media specific function **/
static function base_uri(){
return sprintf(
"%s://%s%s",
isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
);
}
function AddJquery($version = null) {
if($version === null) $version = 'custom';
$js_files[] = '<script src="assets/js/jquery/jquery.' . $version . '.js"></script>';
}
function AddJS($name, $minified = true) {
$js_base_uri = base_uri() . "assets/js/";
$js_files[] = $js_base_uri . ($minified ? '/min/' : '') . $name . ($minified ? '.min' : '') . '.js';
}
/** Page specific function **/
public function index_page() {
if(!empty($js_files)) $js_files = array();
if(!empty($css_files)) $css_files = array();
AddJquery();
AddJS('mainscript');
$data = array(
'js_files' => $js_files
);
return View::make('homepage', $data);
}
}
?>
当我在routes.php中使用Route::get('/', 'MediaController@index_page');
访问我的主页时,在index_page()
中,它无法访问AddJquery()
方法。
任何人都可以告诉我为什么?感谢。