Vue基于iview table展示圖片實(shí)現(xiàn)點(diǎn)擊放大
首先先安裝依賴:
npm install v-viewer --save
然后全局引入,我這邊是在main.js里面操作寫(xiě)的:
import Viewer from ’v-viewer’import ’viewerjs/dist/viewer.css’
然后注冊(cè)下:
Vue.use(Viewer)Viewer.setDefaults({ Options: { ’inline’: true, ’button’: true, ’navbar’: true, ’title’: true, ’toolbar’: true, ’tooltip’: true, ’movable’: true, ’zoomable’: true, ’rotatable’: true, ’scalable’: true, ’transition’: true, ’fullscreen’: true, ’keyboard’: true, ’url’: ’data-source’ }})
使用的一個(gè)demo就是:
<viewer :images='tupians'> <i-col span='4' v-for='item in tupians'> <div class='detailed'> <img :src='http://www.cgvv.com.cn/bcjs/item.img' alt=''> </div> </i-col></viewer>
其中item.img其實(shí)就是一個(gè)路徑。
在回到iview表格中,
需要以
h(’xxxx’, {props: { trigger: ’hover’, placement: ’top’, content: ’二維碼’} }, [ ])
這種格式渲染出來(lái),第一個(gè)參數(shù)是標(biāo)簽,第二參數(shù)是標(biāo)簽里面可以含props(vue的v-bind),也可以包含屬性。第三個(gè)參數(shù)是數(shù)組,表示子標(biāo)簽。子標(biāo)簽也是這種格式的,以此遞歸下去。
所以改寫(xiě)成這種格式的,在本人項(xiàng)目中的一個(gè)demo如下,就可以實(shí)現(xiàn)在表格中點(diǎn)擊圖片進(jìn)行放大展示:
{ title: ’二維碼’, align: ’center’, render: (h, params) => { console.log(’h, param’, params); let devicesArr = []; let photo = []; photo.push(’/erweima/’+params.row.pt_number+’.png’); devicesArr.push( h(’Tooltip’, {props: { trigger: ’hover’, placement: ’top’, content: ’二維碼’} }, [h(’viewer’, { props:{ images:photo }}, [ h(’img’, { attrs: { src:photo[0], style: ’width: 22px;margin-right:5px’ }, })]) ]) ); return h(’div’, devicesArr); }}
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. css代碼優(yōu)化的12個(gè)技巧2. ASP實(shí)現(xiàn)加法驗(yàn)證碼3. PHP循環(huán)與分支知識(shí)點(diǎn)梳理4. 讀大數(shù)據(jù)量的XML文件的讀取問(wèn)題5. jsp實(shí)現(xiàn)登錄界面6. asp批量添加修改刪除操作示例代碼7. 低版本IE正常運(yùn)行HTML5+CSS3網(wǎng)站的3種解決方案8. HTML5 Canvas繪制圖形從入門到精通9. ASP.NET MVC通過(guò)勾選checkbox更改select的內(nèi)容10. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)
