basic\components\HelloWidget
namespace app\components; use yii\base\Widget; use yii\helpers\Html; class HelloWidget extends Widget { public $message; public function init() { parent::init(); if ($this->message === null) { $this->message = ‘您好‘; } } public function run() { return Html::encode($this->message); }
View
[php] view plaincopy在CODE上查看代码片派生到我的代码片 <?php use app\components\HelloWidget; ?> <?= HelloWidget::widget([‘message‘ => ‘组件‘]) ?>
时间: 2024-10-27 18:52:17