谁一开始就是大神?

helper助手Html::ul的问题[2.0]

问题:

$arr = [
    Html::img( '/abc/image1.jpg', [ 'alt' => '头像' ] ), 
    Html::img( '/abc/image2.jpg', [ 'alt' => '头像' ] ), 
];
Html::ul( $arr );

结果:

<li>
    &lt;img src=&quot;/abc/image1.png&quot; alt=&quot;头像&quot; style=&quot;width:50px;height:50px&quot;&gt;
</li>
<li>
    &lt;img src=&quot;/abc/image2.png&quot; alt=&quot;头像&quot; style=&quot;width:50px;height:50px&quot;&gt;
</li>

得到的是转义符而不是html标签了…
哪位大哥求解决下。。。

看yii2源码,这里不想被转义就应该用

Html::ul($arr, ['encode' => false]);

有参数可以设置就是方便
学习了

赞(0) 打赏
未经允许不得转载:菜鸟之家 » helper助手Html::ul的问题[2.0]

评论 抢沙发

登录

找回密码

注册