Vue?+?ElementUI表格內(nèi)實(shí)現(xiàn)圖片點(diǎn)擊放大效果的兩種實(shí)現(xiàn)方式
方式一:使用el-popover彈出框
trigger屬性用于設(shè)置何時觸發(fā)Popover(彈出框)屬性值有:hover、click、focus 和 manual
style="cursor:pointer":當(dāng)鼠標(biāo)放上去時讓img標(biāo)簽出現(xiàn)小手狀態(tài)
<el-table-column label="物品圖片" header-align="center" align="center">
<template slot-scope="scope">
<el-popover placement="top-start" trigger="click"> <!--trigger屬性值:hover、click、focus 和 manual-->
<a :href="scope.row.goodsImg" rel="external nofollow" target="_blank" title="查看最大化圖片">
<img :src="scope.row.goodsImg" style="width: 300px;height: 300px">
</a>
<img slot="reference" :src="scope.row.goodsImg" style="width: 50px;height: 50px; cursor:pointer">
</el-popover>
</template>
</el-table-column>方式二:使用v-viewer插件
一、安裝依賴:在項(xiàng)目目錄文件中進(jìn)入安裝
npm install v-viewer --save

二、全局引入:在項(xiàng)目目錄下 ——> src文件夾下 ——> main.js進(jìn)行全局引入
import Vue from 'vue'
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'
}
})三、使用:在想要的組件中進(jìn)行使用
單張圖片方式
<viewer>
<img
:src="scope.row.goodsImg"
style="width: 50px;height: 50px; cursor:pointer">
</viewer>
// 或
<div v-viewer>
<img
:src="scope.row.goodsImg"
style="width: 50px;height: 50px; cursor:pointer">
</div>多張圖片方式
<div>
<viewer :images="signImages">
<!-- signImages一定要一個數(shù)組,否則報(bào)錯 -->
<img
v-for="(src,index) in signImages"
:src="src"
:key="index"
width="50">
</viewer>
</div>
<!-- signImages數(shù)組放在 export default ——> data() ——> return 里面 -->
signImages: [
'https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=3d9fc10fa3014c08063b2ea53a7a025b/359b033b5bb5c9eac1754f45df39b6003bf3b396.jpg',
'https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=b38f3fc35b0fd9f9bf175369152cd42b/9a504fc2d5628535bdaac29e9aef76c6a6ef63c2.jpg',
'https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=7ecc7f20ae0f4bfb93d09854334e788f/10dfa9ec8a1363279e1ed28c9b8fa0ec09fac79a.jpg'
],說明:
| 名稱 | 默認(rèn)值 | 說明 |
|---|---|---|
| inline | false | 啟用 inline 模式 |
| button | true | 顯示右上角關(guān)閉按鈕 |
| navbar | true | 顯示縮略圖導(dǎo)航 |
| title | true | 顯示當(dāng)前圖片的標(biāo)題 |
| toolbar | true | 顯示工具欄 |
| tooltip | true | 顯示縮放百分比 |
| movable | true | 圖片是否可移動 |
| zoomable | true | 圖片是否可縮放 |
| rotatable | true | 圖片是否可旋轉(zhuǎn) |
| scalable | true | 圖片是否可翻轉(zhuǎn) |
| transition | true | 使用 CSS3 過度 |
| fullscreen | true | 播放時是否全屏 |
| keyboard | true | 是否支持鍵盤 |
| url | src | 設(shè)置大圖片的 url |
參考資料:
https://blog.csdn.net/AdminGuan/article/details/103574434
https://www.cnblogs.com/chenziyu/p/10270934.html
到此這篇關(guān)于Vue + ElementUI表格內(nèi)實(shí)現(xiàn)圖片點(diǎn)擊放大效果的兩種方式的文章就介紹到這了,更多相關(guān)Vue ElementUI圖片點(diǎn)擊放大內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- vue elementUI table表格自定義樣式滾動效果
- Vue+ElementUI表格狀態(tài)區(qū)分,row-class-name屬性詳解
- vue+elementui 表格分頁限制最大頁碼數(shù)的操作代碼
- elementui實(shí)現(xiàn)表格(el-table)默認(rèn)選中功能
- vue elementUi+sortable.js實(shí)現(xiàn)嵌套表格拖拽問題
- Vue+ElementUI踩坑之動態(tài)顯示/隱藏表格的列el-table-column問題
- 使用elementUI的表格table給列添加樣式
- vue基于ElementUI動態(tài)設(shè)置表格高度的3種方法
相關(guān)文章
Vue使用自定義指令實(shí)現(xiàn)拖拽行為實(shí)例分析
這篇文章主要介紹了Vue使用自定義指令實(shí)現(xiàn)拖拽行為,結(jié)合實(shí)例形式分析了Vue使用自定義指令實(shí)現(xiàn)拖拽行為具體步驟、原理與操作注意事項(xiàng),需要的朋友可以參考下2020-06-06
vue自定義加載指令v-loading占位圖指令v-showimg
這篇文章主要為大家介紹了vue自定義加載指令和v-loading占位圖指令v-showimg的示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-08-08
詳解新手使用vue-router傳參時注意事項(xiàng)
這篇文章主要介紹了詳解新手使用vue-router傳參時注意事項(xiàng),詳細(xì)的介紹了幾種常見錯誤,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06
如何使用vue實(shí)現(xiàn)跨域訪問第三方http請求
這篇文章主要介紹了如何使用vue實(shí)現(xiàn)跨域訪問第三方http請求,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友參考下吧2024-03-03
vue2.0 資源文件assets和static的區(qū)別詳解
這篇文章主要介紹了vue2.0 資源文件assets和static的區(qū)別,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-04-04
解決ant Design Search無法輸入內(nèi)容的問題
這篇文章主要介紹了解決ant Design Search無法輸入內(nèi)容的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-10-10
React組件通信之路由傳參(react-router-dom)
本文主要介紹了React組件通信之路由傳參(react-router-dom),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10

