简体   繁体   English

在yii2链接中删除href值

[英]Removing the href value in a yii2 link

I have a menu i have created in yii2 and i would like to remove the href value to # 我有一个在yii2中创建的菜单,我想将href值删除为#

This is what i have done 这就是我所做的

 <?php
            echo Menu::widget([
                'encodeLabels' => false,
                'options' => [
                    'class' => 'topnav menu-left-nest'
                ],
                'items' => [
                    [
                    'label' => ThemeNav::link('Manager action, 'fa fa-user'),

                    'url' => ["#"],  //this is the url {{i}}

                    'options' => ['class' => 'tooltip-tip'],
                    'items' => [

                      ...items in the dropdown
                          ],

When i check on the inspect element The above url ({{i}}) generates a value eg 当我检查检查元素时,上面的URL({{i}})生成一个值,例如

<a href="/webwisekenya/advanced/backend/site/#"></a>

But i would like it to remain as 但我希望它保持原样

<a href="#"></a>

How do i go about this 我该怎么办

This is the themenav class function link 这是themenav类的功能链接

public static function link($label, $icon = null) {

    $link = null;

    if (!empty($icon))
        $link .= Html::tag('i','',['class'=>$icon]);

    $link .= Html::tag('span', $label, []);

    return $link;

}

In Item list spécification, url can be defined as array or string: 在项目列表特殊化中,可以将url定义为数组或字符串:

  • array : for predifined route array :用于预定义的路线
  • string : directly the url 字符串 :直接网址

url var is used with the function Url::to . url var与功能Url :: to一起使用 More info here: http://www.yiiframework.com/doc-2.0/yii-helpers-baseurl.html#to()-detail 此处的更多信息: http : //www.yiiframework.com/doc-2.0/yii-helpers-baseurl.html#to()-detail

Manual about widget menu items: http://www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$items-detail 有关小部件菜单项的手册: http : //www.yiiframework.com/doc-2.0/yii-widgets-menu.html#$items-detail

['label'=> ThemeNav :: link('Manager action,'fa fa-user'),'url'=>'#'],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM