element-ui 伴我成長(zhǎng),遇到的那些坑(一),el-menu 菜單導(dǎo)航相關(guān)

1.設(shè)置彈出窗被選中的樣式

 <el-menu :collapse="true"   class="el-menu-vertical-demo enterpriseslistLocation"    @close="handleClose"  @open="handleOpen" @select="handleSelect"  :default-active="'10'">
<div class="companyLocation">
                      <el-submenu index="1" popper-class="companyPopper">  // popper-class 是給彈出來的子菜單添加樣式
                          <template slot="title">
                              <i class="MenuIconSpriteLocation MenuIconSprite"></i>
                              <span>地區(qū)</span>       
                          </template>
                          <template  v-for="item in cityData" >
                                    <el-menu-item  :index="item.id+''" >   // index 是一個(gè)字符串,所以如果id是數(shù)字的話需要轉(zhuǎn)成字符串,首先
                                      <input type="radio" name="status" :value="item.value" v-model="city" :id="item.id" style="display:none">
                                       <span class="itembuttons" @click="changecitys('',item.value)">
                                          {{item.label}}
                                      </span >   
                                     </el-menu-item> 
                          </template>
                           <el-cascader
                                    change-on-select
                                    :options="procity"
                                    v-model="procitydata"
                                    @change="handleChange"
                                    placeholder="請(qǐng)選擇更多城市"
                                    clearable
                                    style="width: 280px">
                           </el-cascader> 
                      </el-submenu>
                 </div>
</el-menu>

這里的:default-active 意思是觸發(fā)選中el-menu-item 中的對(duì)應(yīng)的index,如果想要要默認(rèn)選中第一項(xiàng)就使用 :default-active =“‘10’”,我這里 子菜單中第一個(gè)index是10所以是“‘10’”,注意這里的值也是字符串;

注意@open="handleOpen" 設(shè)置之后就會(huì)有會(huì)忽視的效果

2.設(shè)置子菜單選中時(shí)候的樣式

    .children  ul li.is-active{
            ……
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容