Yii2 自定义组件
2024-09-02 06:03:04
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' => '组件']) ?>
最新文章
- hibernate延迟加载
- 《转载》Spring MVC之@RequestBody, @ResponseBody 详解
- <;十二>;JDBC_批量处理
- android ContentObserver
- Unity使用protobuf-net进行二进制序列化与反序列化
- LINQ日常使用记录
- 搭建WebRtc环境
- map reduce filter
- <;marquee>;属性详解
- 读懂diff
- 多项分布(multinominal distribution)
- ORA-15025: could not open disk 处理
- MyBatis的分页操作(MySQL)
- CAS单点登录(SSO)完整教程
- YII 小部件实现的注册表
- 【枚举+小技巧】【TOJ4115】【Find the number】
- Windows环境搭建与第一个C# Sample
- python全栈学习--day10(函数进阶)
- spring-boot集成activiti的model遇到问题汇总
- mysql用户管理和pymysql模块
热门文章
- The user specified as a definer (&#39;root&#39;@&#39;%&#39;) does not exist解决
- Spring 讲解(五)
- Ubuntu更新完NVIDIA驱动后,重启电脑进入不了系统,一直处于登录界面
- 四轴遥控器ADC部分
- POJ 1655 Balancing Act (树状dp入门)
- POJ 3187 Backward Digit Sums (dfs,杨辉三角形性质)
- sql中简单的触发器功能
- [CSP-S模拟测试]:简单的玄学(数学)
- tcp和udp得区别
- kafka ProducerConfig 配置