1、iview中引入表格,并在render函数中写入img标签,实现划过标头出现气泡弹窗。
2、由于表格中几乎每个标头都需要出现气泡弹窗并引入图片,故写了公共的样式和图片路径。
3、实现效果:
4、代码实现:
{
title: '期末余额(元)',
width: 140,
key: 'aaa',
render: (h, params) => {
return h('div', [h('strong', params.row.aaa)])
},
renderHeader: (h, params) => {
return h(
'Tooltip',
{
props: { placement: 'top', transfer: true }
},
[
h('span', '期末余额(元)'),
h('img', {
attrs: {
src: this.doubtImg
},
class: 'doubtImgStyle'
}),
h(
'p',
{
slot: 'content',
style: { whiteSpace: 'normal', wordBreak: 'break-all' }
},
'结束日期前未结算实际收款金额合计'
)
]
)
}
},
doubtImg:require('@/assets/images/doubt@2x.png')
注意!!! style样式一定不要写在scope里面,因为scope生成了css模块化,导致渲染不出来样式。
<style>
.doubtImgStyle{
width: 16px;
height: 16px;
position: relative;
top: 4px;
}