Vue基于iview table展示圖片實現(xiàn)點擊放大
首先先安裝依賴:
npm install v-viewer --save
然后全局引入,我這邊是在main.js里面操作寫的:
import Viewer from 'v-viewer'
import 'viewerjs/dist/viewer.css'
然后注冊下:
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' } })
使用的一個demo就是:
<viewer :images="tupians"> <i-col span="4" v-for="item in tupians"> <div class="detailed"> <img :src="item.img" alt=""> </div> </i-col> </viewer>
其中item.img其實就是一個路徑。
在回到iview表格中,
需要以
h('xxxx', { props: { trigger: 'hover', placement: 'top', content: '二維碼' } }, [ ])
這種格式渲染出來,第一個參數(shù)是標簽,第二參數(shù)是標簽里面可以含props(vue的v-bind),也可以包含屬性。第三個參數(shù)是數(shù)組,表示子標簽。子標簽也是這種格式的,以此遞歸下去。
所以改寫成這種格式的,在本人項目中的一個demo如下,就可以實現(xià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); } }
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
- vue3應用elementPlus table并滾動顯示問題
- vue3?el-table結合seamless-scroll實現(xiàn)表格數(shù)據(jù)滾動的思路詳解
- vue中el-table兩個表尾合計行聯(lián)動同步滾動條實例代碼
- vue中獲取滾動table的可視頁面寬度調整表頭與列對齊(每列寬度不都相同)
- vue elementUI table表格數(shù)據(jù) 滾動懶加載的實現(xiàn)方法
- vue element-ui table表格滾動加載方法
- vue iview 隱藏Table組件里的某一列操作
- 淺談vue的iview列表table render函數(shù)設置DOM屬性值的方法
- vue 使用iView組件中的Table實現(xiàn)定時自動滾動效果
相關文章
vue+element樹組件 實現(xiàn)樹懶加載的過程詳解
這篇文章主要介紹了vue+element樹組件 實現(xiàn)樹懶加載的過程,本文通過圖文實例代碼相結合給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10使用FileReader API創(chuàng)建Vue文件閱讀器組件
這篇文章主要介紹了使用FileReader API創(chuàng)建一個Vue的文件閱讀器組件,需要的朋友可以參考下2018-04-04Props傳參v-for后TS報錯對象類型是unknow的解決方案
這篇文章主要介紹了Props傳參v-for后TS報錯對象類型是unknow的解決方案,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友參考下吧2024-03-03vue使用Element組件時v-for循環(huán)里的表單項驗證方法
這篇文章主要介紹了vue使用Element組件時v-for循環(huán)里的表單項驗證方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-06-06vue3?中的toRef函數(shù)和toRefs函數(shù)的基本使用
這篇文章主要介紹了vue3?toRef函數(shù)和toRefs函數(shù),文中介紹了ref和toRef的區(qū)別,ref本質是拷貝,修改響應式數(shù)據(jù)不會影響原始數(shù)據(jù),toRef的本質是引用關系,修改響應式數(shù)據(jù)會影響原始數(shù)據(jù),需要的朋友可以參考下2022-11-11