🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

vue3-image-viewer

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

vue3-image-viewer

```npm i vue3-image-viewer``` 或者/or ```yarn add vue3-image-viewer```

4.4.46
unpublished
Source
npm
Version published
Weekly downloads
51
-28.17%
Maintainers
1
Weekly downloads
 
Created
Source

安装/Installation

npm i vue3-image-viewer 或者/or yarn add vue3-image-viewer

引入/Import

import { Image } from "vue3-image-viewer";
import "vue3-image-viewer/dist/style.css"

使用/Use

<script setup lang="ts">
const imgs = [
  "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
  "https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg",
  "https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg",
];
const images = [
  { url: imgs[0], thumbnail: imgs[0], title: "标题", desc: "描述" },
  { url: imgs[1], thumbnail: imgs[1], title: "标题", desc: "描述" },
  { url: imgs[2], thumbnail: imgs[2], title: "标题", desc: "描述" },
];
</script>

<template>
  <div id="app">
    <div class="image">
      <div class="item" v-for="(item, index) in images" :key="item.url">
        <Image
          :src="item.url"
          :images="images"
          fit="contain"
          width="100%"
          preview
          :aspectRatio="9 / 16"
          hideOnClickModal
          :initialIndex="index"
          loop
        />
      </div>
    </div>

    <div class="viewer">
      <Viewer
        style="width: 100%; height: 100%"
        :images="images"
        navigation
        toolbar
        loop
      />
    </div>
  </div>
</template>

<style lang="less">
html,
body,
#app {
  margin: 0;
  padding: 0;
}
#app {
  width: 800px;
  margin: 100px auto;
  .image {
    display: flex;
    flex-wrap: wrap;
    .item {
      width: 33.3%;
      box-sizing: border-box;
      padding: 0 5px;
    }
  }
  .viewer {
    margin-top: 20px;
    width: 800px;
    height: 500px;
  }
}
</style>

##Image组件说明

传参/Props

参数说明类型默认值
base地址前缀string""
src图片地址string""
tokentoken参数string""
aspectRatio固定宽高比number0
fitobject-fitstring"none"
lazy懒加载booleanfalse
hideOnClickModal点击遮罩关闭预览booleanfalse
initialIndex初始预览图像索引number0
preview是否开启预览booleanfalse
images预览列表array[]
loop开启循环booleanfalse
preload预览预加载array or boolean[0,2]
width盒子宽度string""
height盒子高度string""
altaltstring""
referrerPolicy referrerPolicystring""
bgColor背景颜色string"black"

参数说明/Props PS

  • src: 如果src是绝对地址,则base, token不生效,如果是相对地址,返回base+src+?token="abc"
  • aspectRatio: 如果设置了aspectRatio,则高度由宽度和aspectRatio决定
  • lazy: 如果设置了懒加载,则会监听第一个设置了滚动的父元素的滚动事件
  • preload: 如果设置为false则关闭预加载,如果设置为[1,2],则在查看当前图片的同时会同时加载左边1张右边2张图片

组件事件/Event

  • error: 图片加载出错事件/ Same as native error
  • load: 图片加载完成事件/ Same as native load
  • close: 关闭预览事件 / Emit when close the preview
  • switch: 切换预览图片事件,返回下标 / Emit when switch the preview, return current index

支持插槽/Slot

  • error:加载出错占位/ Triggers when image load failed
  • loading:加载中占位/ Triggers when image is loading
  • footer:图片底部占位/ Placeholder on the bottom

##Viewer组件说明

传参/Props 【文档还在写】

参数说明类型默认值
images图片列表array[]
navigation底部预览条booleanfalse
toolbar工具栏booleanfalse

预览效果/Preview

预览效果 预览效果

补充说明

联系我/Contact me

Keywords

vue3

FAQs

Package last updated on 24 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts