![](/img/trans.png)
[英]How to Customizing/add a class to the ActiveForm items with Material Bootstrap design classes on Yii2
[英]Yii2: How to renderPartial with Bootstrap classes?
我正在嘗試使用renderPartial函數和Bootstrap類。
這是我在控制器文件中的功能:
public function actionPrintReport() {
Yii::$app->response->format = 'pdf';
return $this->renderPartial('_myReport', []);
}
這是呈現的_myReport文件:我自己的樣式有效,但Bootstrap類無效。
<div class="box box-warning">
<div class="box-body">
Text
</div>
</div>
但是結果不顯示任何Bootstrap類:
我也嘗試了renderAjax但結果相同。
好吧,這就是函數renderPartial()的意義所在。
渲染視圖而不應用布局。
此方法與render()的不同之處在於它不應用任何布局。
當您在一頁中多次渲染同一代碼塊時,通常會使用renderPartial函數。 您在這里的預期結果是什么? 你想做什么?
通常將registerAssets加載到主視圖文件(未呈現的文件)中。 您應該查看主布局文件,並了解如何加載資產。
你需要:
Asset::register($this);
在您看來_myReports
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.