2016-09-14 71 views

回答

0

您可以在視圖或控制器中添加一個檢查添加當前頁面的檢查:

if(Yii::$app->controller->id == 'foo' && Yii::$app->controller->action->id == 'bar') 
    { 
     // for inside controller check 
     $this->registerJs("your_js_file_path"); 
    } 

    ... html here ... 
    <? 
    if(Yii::$app->controller->id == 'foo' && Yii::$app->controller->action->id == 'bar') 
    {?> 
     <!-- for inside controller check --> 
     <script src=""></script> 
    <?}?> 
    ... html here ...