手機版(使用vant)
未放大效果:

點擊放大后的效果:

html:
<div class="distribution-map-area">
<div class="content">
<van-tabs
v-model="distributionMap"
line-width="1.8rem"
background="transparent"
color="#0743EA"
title-active-color="#0743EA"
>
<van-tab
:title="item.title"
v-for="(item, index) in mapList"
:key="`map_${index}`"
>
<img style="width: 500px;height: 500px;" :src="item.img" @click="previewImg(item.img)" alt="" />
</van-tab>
</van-tabs>
</div>
</div>
js:
<script>
import { ImagePreview } from "vant";
export default {
name: "m-index",
components: {
},
computed: {},
data() {
return {
distributionMap: 0,
mapList: [
{
title: "會場平面分布圖",
img: `${this.JTLM_IMG_HOST}/venue_map2022_01.png`,//圖片地址
},
// {
// title: '展區(qū)平面分布圖',
// img: `${this.JTLM_IMG_HOST}/venue_map2022_2.png`
// },
],
};
},
created() {
},
mounted() {
},
methods: {
//點擊放大查看圖片
previewImg(url) {
ImagePreview([url]);
},
//直接使用(html+vue+vant可使用此寫法)
previewImg(url) {
vant.ImagePreview({
images: [url],
});
},
},
};
</script>
pc端:
html:
<div class="conference-distribution-map-cont">
<div
class="conference-distribution-map-item-cont"
v-for="(item, index) in mapCont"
:key="index"
v-show="mapIdx == index"
>
<el-image
class="conference-distribution-map-item-img"
:src="item.img"
:preview-src-list="item.darkImgList"
>
</el-image>
</div>
</div>
js:
<script>
import comItemTitle from "@/components/common/com-item-title.vue";
import globals from "@/assets/js/global_val.js";
export default {
name: "conference-distribution-map",
components: {
comItemTitle,
},
data() {
return {
mapCont: [
{
img: `${this.JTLPC_IMG_HOST}/venue_map2022.png?v=${globals.timeStamp}`,
darkImgList: [
`${this.JTLPC_IMG_HOST}/venue_map2022.png?v=${globals.timeStamp}`,
],
},
],
};
},
computed: {},
watch: {},
methods: {
},
created() {},
mounted() {},
beforeCreate() {},
beforeMount() {},
beforeUpdate() {},
updated() {},
beforeDestroy() {},
destroyed() {},
activated() {},
};
</script>
文章來源地址http://www.zghlxwxcb.cn/news/detail-716475.html
文章來源:http://www.zghlxwxcb.cn/news/detail-716475.html
到了這里,關于vue 圖片點擊放大查看大圖(element-ui與vant)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!