最近在擼一個電商網(wǎng)站,有一個需求是要像淘寶商品詳情頁那樣,鼠標(biāo)放在主圖上,顯示圖片放大鏡效果,找了一下貌似沒有什么合適的vue插件,于是自己擼了一個,分享一下。小白第一次分享,各位大神莫見笑。
vue-piczoom
picture magnifier component for Vue.js 2.x
基于vue2.x的電商圖片放大鏡插件
GIF 動畫截圖
Build Setup 使用步驟
# 安裝 install npm install vue-piczoom --save
使用 use
--script
import PicZoom from 'vue-piczoom' export default { name: 'App', components: { PicZoom } }
--html
<pic-zoom url="static/imac2.jpg" :scale="3"></pic-zoom>
Config 配置
props | describe | default |
---|---|---|
url | 圖片地址 | string required |
big-url | 大圖地址 | string null |
scale | 圖片放大倍數(shù) | number 2.5 |
scroll | 放大時頁面是否可滾動 | boolean fasle |
Suggest 注意事項(xiàng)
組件默認(rèn)是100%的高寬,所以建議將組件包含在一個有固定高寬的容器內(nèi)。如:
<div class="pic-box"> <!--pic-box:width:500px;height:500px--> <pic-zoom url="static/imac2.jpg" :scale="3"></pic-zoom> </div>
Demo 示例:在線示例 https://826327700.github.io/vue-piczoom/dist/
Github:https://github.com/826327700/vue-piczoom
聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com