移动端要想达到图片预览,可以使用mui.previewimage.js插件。
以下是一个简单的案例,如果只是想要简单的预览效果,可参考下面的使用方法:
效果如下:
html:
<ul>
<li>
<img src="https://img1.baidu.com/it/u=3217543765,3223180824&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1660323600&t=bae3cb736682cbac84e9981303135e1f" data-preview-src="https://img1.baidu.com/it/u=3217543765,3223180824&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1660323600&t=bae3cb736682cbac84e9981303135e1f" data-preview-group="1"/>
</li>
<li>
<img src="https://img2.baidu.com/it/u=1572613686,938558453&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1660323600&t=d7de42afdf92266fbf9f9ac572ca2cde" data-preview-src="https://img2.baidu.com/it/u=1572613686,938558453&fm=253&app=120&size=w931&n=0&f=JPEG&fmt=auto?sec=1660323600&t=d7de42afdf92266fbf9f9ac572ca2cde" data-preview-group="1"/>
</li>
<li>
<img src="https://img1.baidu.com/it/u=1966616150,2146512490&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1660323600&t=ecde87efa68ab3e448e2c35347d8e5c4" data-preview-src="https://img1.baidu.com/it/u=1966616150,2146512490&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1660323600&t=ecde87efa68ab3e448e2c35347d8e5c4" data-preview-group="1"/>
</li>
</ul>
js:
<script src="js/mui.js"></script>
<script src="js/mui.zoom.js"></script>
<script src="js/mui.previewimage.js"></script>
css:
*{margin: 0;padding:0;}
ul li{list-style: none;width: 100px;height: 100px;margin-right: 10px;float: left;}
ul li img{width: 100%;height: 100%;}
其中,相关的插件可从以下地址在码云克隆获得:
https://gitee.com/deng_zi_yan/mui-about.git