第一部分(简单使用)
安装 cnpm install vue-piczoom --save
使用 vue-piczoom
<template>
<div>
<div class="box">
<pic-zoom :url="imgurl" :scale="3"></pic-zoom>
</div>
<div class="list">
<ul>
<li
v-for="(item, index) in imagesList"
:key="index"
@mouseenter="changeImage(index)"
>
<img :src="item" />
</li>
</ul>
</div>
</div>
</template>
<script>
import PicZoom from "vue-piczoom";
export default {
data() {
return {
// imgurl:'',
imgurl: require("../../../assets/image/class10/my_imgbig1.png"),
imagesList: [
require("../../../assets/image/class10/my_imgbig1.png"),
require("../../../assets/image/class10/my_imgbig2.png"),
require("../../../assets/image/class10/my_imgbig3.png"),
],
};
},
components: {
PicZoom,
},
methods: {
changeImage(index) {
this.imgurl = this.imagesList[index];
},
},
};
</script>
<style scoped>
.box {
width: 400px;
height: 320px;
}
.list {
width: 400px;
height: 130px;
}
.list ul {
width: 400px;
display: flex;
justify-content: space-around;
}
.list ul li {
width: 120px;
height: 90px;
background-color: white;
margin-top: 15px;
}
.list ul li img {
width: 120px;
height: 90px;
}
</style>
效果图