ImagePreview 图片预览
基础用法
直接传入图片数组,即可展示图片预览
ImagePreview([
'https://img.yzcdn.cn/1.jpg',
]);
传入配置项
通过传入配置对象,可以指定初始图片的位置、监听关闭事件
const instance = ImagePreview({
images: [
'https://img.yzcdn.cn/1.jpg',
'https://img.yzcdn.cn/2.jpg'
],
asyncClose: true
});
setTimeout(() => {
instance.close();
}, 1000);
组件调用
如果需要在图片预览内嵌入组件或其他自定义内容,可以使用组件调用的方式,调用前需要通过 Vue.use
注册组件
export default {
data() {
show: false,
index: 0,
images: [
'https://img.yzcdn.cn/1.jpg',
'https://img.yzcdn.cn/2.jpg'
]
};
methods: {
onChange(index) {
this.index = index;
}
}
API
Options
通过函数调用 ImagePreview
时,支持传入以下选项:
Events
通过组件调用 ImagePreview
时,支持以下事件:
Slots
通过组件调用 ImagePreview
时,支持以下插槽: