vue-preview的使用

使用vue-preview做图片缩率图
1.安装 npm i vue-preview -S
2.如果使用vue-cli生成的项目,需要修改webpack.base.conf.js文件中的loaders,添加一个loader
{
test:/vue-preview.src.*?js$/,
loader:'babel'
}

3.导入:import VuePreview from 'vue-preview'

使用: Vue.use(VuePreview)


<div class="thumbs">
<img class="preview-img" v-for="(item, index) in list" :src="item.src" height="100" @click="$preview.open(index, list)" :key="item.src">
</div>


注意:img标签上的class="preview-img" 不能去掉,图片要设置宽和高

原文地址:https://www.cnblogs.com/huanhuan55/p/9700547.html