vue-preview

因为已经更新缩略图,使用方法已经发生转变,所以才会找不到$preview


控制台错误信息

"$preview" is not defined on the instance but referenced during render

vue-preview(官网)
npm i vue-preview -S

main.js引用

import VuePreview from 'vue-preview'

// defalut install
Vue.use(VuePreview)

css样式

.thumbs {
  /deep/ .my-gallery{   //deep深层作用选择器
        display: flex;
        flex-wrap:wrap;//默认换行
        figure{
            width: 30%;
            margin: 5px;
            img{
                width: 100%;
                box-shadow: 0 0 8px #999;
                border-radius: 5px;
        }
    }
}

Examples

<template>
   <div class="thumbs">
        <vue-preview :slides="slide1" @close="handleClose"></vue-preview>
   </div>
</template>

<script>
export default {
    data () {
      return {
        slide1: [
          {
            src:  'https://ss3.bdstatic.com/iPoZeXSm1A5BphGlnYG/skin/414.jpg?2',
            msrc: 'https://ss3.bdstatic.com/iPoZeXSm1A5BphGlnYG/skin/414.jpg?2',
            alt: 'picture1',
            title: 'Image Caption 1',
            w: 600,
            h: 400
          }
        ]
      }
    },
    methods: {
      handleClose () {
        console.log('close event')
      }
    }
  }
</script>

实际展示
F3285381-9E34-4034-BC89-4A617489D165.png


diuren1205
57 声望5 粉丝

I love coding