一、点击图片实现跳转
$img = Html::a(Html::img(ImageHelper::src($model->cover)), Url::to(['/default/view', 'id' => $model->id]));
$aImg = Html::a(Html::img(\grazio\image\helpers\ImageHelper::src($model->image), ['class' => 'mr-3 news-img', 'width' => 100]), Url::to(['/news/default/view', 'id' => $model->id]));
<?= Html::a(Html::img($this->theme->getAssetUrl('images/logo.png')), Url::to(['/']),['class' => 'bar']) ?>
<?= Html::a(Html::img(\grazio\image\helpers\ImageHelper::src($model->cover), ['width' => 300]), Url::to(['view', 'id' => $model->id]));?>
<?= Html::a(Html::img($this->theme->getAssetUrl('images/leader-banner.jpg')), Url::to(['/volunteer'])) ?>
二、点击标题或者文字实现跳转
$h5 = Html::a(Html::tag('h5', $model->book_name, ['class' => 'title']), Url::to(['/curriculum/default/view', 'id' => $model->id]));
三、点击按钮返回上一个页面
<?= Html::a(Html::button('返回', ['class' => 'btn btn-primary']), Yii::$app->request->referrer) ?></a>
四、结合条件使用
<?= !empty($model->usersAttachment) ? Html::a(Html::img(Yii::getAlias('@uploadUrl' . $model->usersAttachment[0]->attachment), ['width' => 100]), Url::to(['/users/id/' . $model->id])) : '' ?>
<?= Html::a(isset($model->project->district) ? str_replace(',', '', $model->project->district->mername) : '', Url::to(['/users/id/' . $model->id])) ?>