vue+iview tabs context-menu 彈出框修改樣式的方法
今天遇到一個需求說頁面頂部的菜單右鍵彈出框離得有點遠
代碼是這樣
<Tabs type="card" closable class="main-tags-col-tabs" v-model="activeTab" @on-click="handleClickTag" :before-remove="handleBeforeRemove" capture-focus @on-contextmenu="contextmenu"> <TabPane v-for="(item, index) in tagList" :key="index" :name="item.name" :label="item.label" icon="custom iconfont icon-dot-circle" :closable="index != 0" :context-menu="index == 0 ? false : true" ></TabPane> <template slot="contextMenu"> <DropdownItem @click.native="handleCloseTag('closeOther')"> <Icon type="md-close"></Icon> <span class="dropdown-icon-space">關閉其他</span> </DropdownItem> <DropdownItem @click.native="handleCloseTag('closeAll')"> <Icon type="ios-close-circle-outline"></Icon> <span class="dropdown-icon-space">關閉所有</span> </DropdownItem> </template> </Tabs>
表現(xiàn)出來是這樣
首先打開控制臺,找到這個樣式是 ivu-dropdown-transfer
發(fā)現(xiàn)這個樣式是自帶了transfer
那么在style里面寫scoped 就不會生效,不寫的話是全局了又會影響其他地方下拉框
然后去官網找 transfer-class-name 發(fā)現(xiàn)tabs沒有這個選項
那只能在右鍵時候動態(tài)往里添加了
@on-contextmenu="contextmenu"
contextmenu(item) { this.$nextTick(() => { const dropdownMenu = document.querySelector('.ivu-dropdown-transfer') console.log(dropdownMenu) if (dropdownMenu) { dropdownMenu.classList.add('fixed-context-menu') } }) this.contextMenuActiveName = item.name },
ivu-dropdown-transfer 這里注意ivu-select-dropdown找不到的好像和下拉框的樣式有沖突
然后全局寫一個樣式
<style> .fixed-context-menu { top: 97px !important; } </style>
到此這篇關于vue+iview tabs context-menu 彈出框修改樣式的方法的文章就介紹到這了,更多相關vue+iview tabs context-menu 彈出框內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Vue項目Element表格對應字段映射顯示方法:formatter格式化數(shù)據(jù)問題
這篇文章主要介紹了Vue項目Element表格對應字段映射顯示方法:formatter格式化數(shù)據(jù)問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-07-07Vue.js第一天學習筆記(數(shù)據(jù)的雙向綁定、常用指令)
這篇文章主要為大家分享了Vue.js第一天的學習筆記,包括數(shù)據(jù)的雙向綁定、常用指令學習,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12Vue3異步數(shù)據(jù)加載組件suspense的使用方法
前端開發(fā)中異步請求是非常常見的事情,比如遠程讀取圖片,調用后端接口等等,這篇文章主要給大家介紹了關于Vue3異步數(shù)據(jù)加載組件suspense的使用方法,suspense中文含義是懸念的意思,需要的朋友可以參考下2021-08-08vue關于this.$refs.tabs.refreshs()刷新組件方式
這篇文章主要介紹了vue關于this.$refs.tabs.refreshs()刷新組件方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03Vuex的插件vuex-persistedstate數(shù)據(jù)持久化存儲操作
這篇文章主要介紹了Vuex的插件vuex-persistedstate數(shù)據(jù)持久化存儲操作,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧2023-12-12Vue 實現(xiàn)v-for循環(huán)的時候更改 class的樣式名稱
這篇文章主要介紹了Vue 實現(xiàn)v-for循環(huán)的時候更改 class的樣式名稱,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07