Php yii2中导航栏的外部链接

Php yii2中导航栏的外部链接,php,yii2,Php,Yii2,刚才,我尝试了向导航栏添加链接。比如, menuItems[] = ['label' => 'Test', 'url' => ['http://www.google.com']]; 但我看到,任何时候yii2都会向每个地址添加baseUrl。我也这样做了 文件:\vendor\yiisoft\yii2\helpers\BaseHtml.php 之前: public static function a($text, $url = null, $options = []) {

刚才,我尝试了向导航栏添加链接。比如,

menuItems[] = ['label' => 'Test', 'url' => ['http://www.google.com']];
但我看到,任何时候yii2都会向每个地址添加baseUrl。我也这样做了

文件:\vendor\yiisoft\yii2\helpers\BaseHtml.php

之前:

public static function a($text, $url = null, $options = [])
    {
        if ($url !== null) {
            $options['href'] = Url::to($url);
        }
        return static::tag('a', $text, $options);
    }
之后:

public static function a($text, $url = null, $options = [])
        {
            if ($url !== null) {
                $options['href'] = Url::to($url,'http');
            }
            return static::tag('a', $text, $options);
        }

这很有效,但我不知道,是真的吗?您认为呢?

对于外部链接,只需使用原始字符串格式:

menuItems[] = ['label' => 'Test', 'url' => 'http://www.google.com'];

这部作品没有原始格式
$menuItems[]=['label'=>'Test','url'=>null','linkOptions'=>['href'=>'http://www.google.com']];

我现在明白了:)就是这样。我又变了