https://github.com/xLogic92/vue-picture-preview
一、vue-picture-preview (只能实现图片的预览,不能实现图片的放大功能)
安装
yarn add vue-picture-preview
使用
import vuePicturePreview from 'vue-picture-preview'Vue.use(vuePicturePreview)
在根组件中添加lg-preview组件的位置
<div id="app"><router-view></router-view><lg-preview></lg-preview></div>
<template><div class="home"><template v-for="(item,index) of images" ><imgv-preview="item.imgUrl"preview-title-enable="true"preview-nav-enable="true":src="item.imgUrl":alt="index+1+'/'+images.length" :key="item.id"/></template></div></template><script>import localData from "@/data/data.js";export default {name: "home",data(){return {images:localData}}}</script><style scoped>.home{display: grid;grid-template-columns: repeat(2,350px);grid-gap: 10px 10px;}</style>
var localData = [{ imgUrl: "http://img1.qunarzz.com/sight/p0/1501/10/1012e4a2c398409c.water.jpg_350x240_56977146.jpg", id: 1000 },{ imgUrl: "http://img1.qunarzz.com/sight/p0/201405/27/94685f45252d4f782f6545a7586e9daa.jpg_350x240_bfb5f7e5.jpg", id: 1001 },{ imgUrl: "http://img1.qunarzz.com/sight/p0/201405/27/94685f45252d4f782f6545a7586e9daa.jpg_350x240_bfb5f7e5.jpg", id: 1002 },{ imgUrl: "http://img1.qunarzz.com/sight/p0/201301/14/c14bcd857b804ca393835fbb.jpg_350x240_d84595e3.jpg", id: 1234 },{ imgUrl: "http://img1.qunarzz.com/sight/p0/1509/fb/4bd1b1c83f5bc033ff36093b91294021.water.jpg_350x240_feb831ff.jpg", id: 1115 },{ imgUrl: "http://img1.qunarzz.com/sight/p0/1412/5c/b921bad6734a811e28c2c8f7a22f83ba.water.jpg_350x240_874af7bd.jpg", id: 1116 },]
二、vue-preview
支持滑动换图,支持手势缩放,显示当前时第几张和总共多少张
https://ls1231.github.io/vue-preview/
yarn add vue-preview
Tips:字段要和官网的写成一样。
