1.0.6 • Published 11 months ago

image-view v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

image-view

组件介绍

image-view是一个点击图片放大的组件,支持原位置进行运动放大,缩小至原位置交互体验,如下图:https://xydideo.gitee.io/blog/public-image/image-view.gif

图片预览

组件依赖

vue3、less(vue2也支持)

组件使用

<template>
  <div class="page">
    <div>
      <img :src="item" alt="" srcset="" v-for="(item,index) in list" :key="index" @click="handleClick">
    </div>

    <image-view ref="imgViewRef" :isShow="isShow" @close="isShow=false" />
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue"

// 引入组件
import { ImageView } from 'image-view'
import 'image-view/style.css'

// 获取全局在main.js中引入
// import ImageView from 'image-view'
// import 'image-view/style.css'
// app.use(ImageView)

const imgViewRef = ref(null)
const isShow = ref(false)
const list = ref([
  "https://mail.qq.com/zh_CN/htmledition/images/favicon/qqmail_favicon_96h.png",
  "https://undesign.learn.uno/icon.png",
  "https://cdn.apifox.cn/logo/apifox-logo-512.png",
])

// 点击图片
function handleClick(event) {
  isShow.value = true
  imgViewRef.value.imageView(event)
}
</script>

<style lang="less" scoped>
img {
  width: 100px;
  height: 100px;
  margin: 12px;
}
</style>

组件api

Props

参数说明类型默认值
isShow是否显示预览Booleanfalse
bgOpacity背景色的不透明度Number0.96

Events

参数说明回调参数
close关闭预览-
imageView图片预览(子组件的方法)通过refs进行调用,传当前点击图片的event-
1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago