Yii2 layout 由 controller 向layout中傳遞引數值

大飛_dafei發表於2018-11-25
// controller
    public function actionIndex()
    {
     
        Yii::$app->view->params['model'] = "hello world";

        return $this->render('index');
    }
//layout main.php
$model = $this->params['model'];  獲取 hello world

 

相關文章