2016-08-16 11:09:18 4857次浏览 2条回答 2 悬赏 10 金钱

BaseHtml类里

public static function img($src, $options = [])
{
    $options['src'] = Url::to($src);
    if (!isset($options['alt'])) {
        $options['alt'] = '';
    }
    return static::tag('images', '', $options); 
}

解析出来的代码是前后image 竟是闭合的image标签

此bug导致formater里的image也是不能用的

解决方法

修改BaseHtml类的源码

public static function img($src, $options = [])
{
    $options['src'] = Url::to($src);
    if (!isset($options['alt'])) {
        $options['alt'] = '';
    }
    return static::tag('img', '', $options);
}
  • 回答于 2016-08-17 08:41 举报

    沙发,赞个

  • 回答于 2016-08-18 09:41 举报

    哥们感谢你的提醒,不晓得你修改的是哪个版本的,我现在的是v2.0.9,我看了baseHtml是OK的啊。

     /**
         * Generates an image tag.
         * @param array|string $src the image URL. This parameter will be processed by [[Url::to()]].
         * @param array $options the tag options in terms of name-value pairs. These will be rendered as
         * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
         * If a value is null, the corresponding attribute will not be rendered.
         * See [[renderTagAttributes()]] for details on how attributes are being rendered.
         * @return string the generated image tag
         */
        public static function img($src, $options = [])
        {
            $options['src'] = Url::to($src);
            if (!isset($options['alt'])) {
                $options['alt'] = '';
            }
            return static::tag('img', '', $options);
        }
    
    1 条回复
    回复于 2016-08-19 09:15 回复

    这应该是以前某个版本的bug 应该是2.0.8版本的 2.0.9版本的没有这个问题

    觉得很赞
您需要登录后才可以回答。登录 | 立即注册
且试天下
副总裁

且试天下 日本东京

注册时间:2015-10-22
最后登录:2天前
在线时长:75小时16分
  • 粉丝64
  • 金钱5090
  • 威望160
  • 积分7440

热门问题