vue實(shí)現(xiàn)element表格里表頭信息提示功能(推薦)
如圖:在element表格操作一欄需要添加提示功能
實(shí)現(xiàn)效果
如圖:鼠標(biāo)浮上去彈出tips
解決方案
1、編寫組件
在 promptMessage.vue 文件里面實(shí)現(xiàn)
<template>
<!-- 處理element表格表頭文字提示特別添加全局注冊組件 -->
<div class="promt-message-tooltip">
<el-tooltip effect="light" placement="left">
<div slot="content">
<p v-for="item in messages" :key="item">
{{item}}
</p>
</div>
<i class="el-icon-question" class="tips-icon"></i>
</el-tooltip>
</div>
</template>
<script>
export default {
props: ['messages']
}
</script>
<style lang="scss">
.promt-message-tooltip {
.tips-icon {
color:#409eff;
margin-left:5px;
font-size:14px;
}
}
</style>
2、開發(fā)插件
在 index.js 文件里面實(shí)現(xiàn)
import promptMessage from './promptMessage.vue'
export default {
install: (Vue) => {
Vue.component('promptMessage', promptMessage)
}
}
3、使用插件
在 main.js 文件里面實(shí)現(xiàn)
import promptMessage from '@/components/promptMessage/index.js' Vue.use(promptMessage)
4、業(yè)務(wù)代碼實(shí)現(xiàn)
<template>
<el-table tooltip-effect="light" :data="dataList" border >
<el-table-column label="操作" :render-header="renderHeader">
<template slot-scope="scope">刪除</template>
</el-table-column>
</el-table>
</template>
<script>
export default {
methods: {
// render 事件
renderHeader (h, { column }) {
return h(
'div', {
style: 'display:flex;margin:auto;'
},
[
h('span', column.label),
// 直接用組件就完事了
h('prompt-message', {
props: { messages: ['kaimo需要的tips!'] }
})
]
)
}
}
}
</script>
總結(jié)
以上所述是小編給大家介紹的vue實(shí)現(xiàn)element表格里表頭信息提示功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
vue項(xiàng)目中,main.js,App.vue,index.html的調(diào)用方法
今天小編就為大家分享一篇vue項(xiàng)目中,main.js,App.vue,index.html的調(diào)用方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09
vue-cli打包后本地運(yùn)行dist文件中的index.html操作
這篇文章主要介紹了vue-cli打包后本地運(yùn)行dist文件中的index.html操作,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-08-08
解決vue中axios設(shè)置超時(shí)(超過5分鐘)沒反應(yīng)的問題
這篇文章主要介紹了解決vue中axios設(shè)置超時(shí)(超過5分鐘)沒反應(yīng)的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09

