ImageViewer 图片查看器

Scan me!

用于浏览多张图片,并可对图片进行滑动切换

引入

  1. import { ImageViewer } from 'mand-mobile'
  2. Vue.component(ImageViewer.name, ImageViewer)

代码演示

基本

请在移动设备中扫码预览
  1. <template>
  2. <div class="md-example-child md-example-child-image-reader">
  3. <div>
  4. <ul>
  5. <template v-for="(item, index) in imgs">
  6. <li @click="showViewer(index, $event)" :key="index">
  7. <div class="img"
  8. :style="`background: url(${item}) center no-repeat;background-size:cover;`">
  9. </div>
  10. </li>
  11. </template>
  12. </ul>
  13. </div>
  14. <md-image-viewer
  15. v-model="isViewerShow"
  16. :list="imgs"
  17. :has-dots="true"
  18. :initial-index="viewerIndex">
  19. </md-image-viewer>
  20. </div>
  21. </template>
  22. <script>
  23. import {ImageViewer} from 'mand-mobile'
  24. export default {
  25. name: 'image-viewer-demo',
  26. components: {
  27. [ImageViewer.name]: ImageViewer,
  28. },
  29. data() {
  30. return {
  31. isViewerShow: false,
  32. viewerIndex: 0,
  33. imgs: [
  34. 'http://img-hxy021.didistatic.com/static/strategymis/insurancePlatform_spu/uploads/27fb7f097ca218d743f816836bc7ea4a',
  35. 'http://manhattan.didistatic.com/static/manhattan/insurancePlatform_spu/uploads/c2912793a222eb24b606a582fd849ab7',
  36. 'http://img-hxy021.didistatic.com/static/strategymis/insurancePlatform_spu/uploads/6ee5a0ba9340ca452cbc827902e76be0',
  37. 'http://img-hxy021.didistatic.com/static/strategymis/insurancePlatform_spu/uploads/d751dd4487e265de3b8587f504eee2c3',
  38. ],
  39. }
  40. },
  41. methods: {
  42. showViewer(index) {
  43. this.viewerIndex = index
  44. this.isViewerShow = true
  45. },
  46. },
  47. }
  48. </script>
  49. <style lang="stylus" scoped>
  50. .md-example-child-image-reader
  51. float left
  52. width 100%
  53. ul
  54. float left
  55. width 100%
  56. li
  57. position relative
  58. float left
  59. width 22%
  60. padding-bottom 22%
  61. margin-left 2%
  62. margin-top 2%
  63. border-sizing border-box
  64. border-radius 2px
  65. overflow hidden
  66. list-style none
  67. .img
  68. position absolute
  69. width 100%
  70. height 100%
  71. </style>
  72.  

API

ImageViewer Props

属性说明类型默认值备注
v-model1.1.0+是否显示查看器Booleanfalse
list展示图片列表Array[]-
initial-index初始索引值Number0-
has-dots是否展示图片索引值Booleantrue-