安装vue-preview组件

npm i vue-preview -S

main.js文件:

import VuePreview from 'vue-preview';
Vue.use(VuePreview); // 内部会原型 Vue.component('vue-preview', {})

vue文件:

//html部分
<vue-preview :slides="imgData" @close="handleClose"></vue-preview>

//js部分
data() {
    return {
        imgData: [
        {
          id: 1,
          src: 'static/img/001.jpg',
          msrc: 'static/img/001.jpg',
          w: 600,
          h: 400
        },
        {
          id: 2,
          src: 'static/img/002.jpg',
          msrc: 'static/img/002.jpg',
          w: 600,
          h: 400
        },
        {
          id: 3,
          src: 'static/img/003.jpg',
          msrc: 'static/img/003.jpg',
          w: 600,
          h: 400
        },
        {
          id: 4,
          src: 'static/img/004.jpg',
          msrc: 'static/img/004.jpg',
          w: 600,
          h: 400
        },
      ]
    }
}

 

相关文章:

  • 2021-12-22
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
猜你喜欢
  • 2022-01-13
  • 2021-12-21
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案