npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

v3-img-preview

v1.1.16

Published

vue3图片预览插件

Downloads

162

Readme

v3-img-preview

github MIT vue2.x GitHub Repo stars

简介

基于vue3编写的图片预览插件,支持单图和多图预览,支持图片旋转,缩放,移动等功能

安装

npm install v3-img-preview --save
# or
yarn add v3-img-preview

在main.js中引入

import { createApp } from 'vue'
import App from './App.vue'
import v3ImgPreview from 'v3-img-preview'
const app = createApp(App)
app.mount('#app')
app.use(v3ImgPreview, {/* 全局配置 */})

在组件中使用

组件支持两种调用方式:经过app.use注册后,全局属性上会绑定$v3ImgPreviewFn方法,可以直接调用,您也可以通过直接导入v3ImgPreviewFn方法使用,使用方式如下:


<template>
  <div class="box">
    <button @click="handleClick">导出方法调用</button>
    <button @click="handleImgPreview">实例调用</button>
  </div>
</template>

<script>
import { defineComponent} from 'vue'
import { v3ImgPreviewFn } from 'v3-img-preview'
export default defineComponent({
  name: 'ServeDev',
  components: {},
  setup() {
    const instance = getCurrentInstance()
    const handleClick = () => {
      // 导出方法调用
      v3ImgPreviewFn(
          'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF'
        )
    }
    // or 
    const  handleImgPreview = () => {
      // 全局方法调用
      instance.proxy.$v3ImgPreviewFn('https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF')
    }
    return { handleClick,handleImgPreview }
  }
})
</script>

本地预览

import { v3ImgPreviewFn } from 'v3-img-preview'
const imgU

rl1 = require('./images/1.jpg')
const imgUrl2 = require('./images/2.jpg')
// 单张图片
v3ImgPreviewFn(imgUrl1)

// 多张图片
v3ImgPreviewFn({images : [imgUrl1, imgUrl2]})
// or
v3ImgPreviewFn([imgUrl1, imgUrl2])

API

以下属性适用于传递对象时使用,若只传递url,您也可以直接调用方法传递 v3ImgPreviewFn("http://www.xxxxxx.png")

| 属性 | 说明 | 类型 | 默认值 | | ------------ | -------------------------------------------------------- | --------- | ------ | | url | 图片url | string | - | | keyboard | 是否使用键盘快捷键 | boolean | true | | images | 图片数组,用于展示多个图片时,可以使用该属性传递多张图片 | Array | - | | escClose | 是否支持esc关闭,注意:keyboard禁用时此功能也将禁用 | boolean | true | | showCloseBtn | 是否显示关闭按钮 | boolean | true | | showToolbar | 是否显示工具栏 | boolean | true | | showArrowBtn | 是否显示左右箭头 | boolean | true |

全局配置方式

我们所有的API都支持全局配置,您可以在注册插件的时候配置全局属性

import { createApp } from 'vue'
import App from './App.vue'
import VImagesPreview from 'v3-img-preview'
const app = createApp(App)
app.mount('#app')
// 全局配置属性
app.use(VImagesPreview, { keyboard: false,escClose: false,showToolbar: false })

配置优先级

配置项的优先级为 组件内传入配置 > 全局配置 > 默认值

快捷键

| 快捷键 | 说明 | | ------- | --------- | | A ← | 上一张 | | D → | 下一长 | | S ↓ | 缩小 | | W ↑ | 放大 | | Q | 左旋转90° | | E | 右旋转90° | | Space | 复位 |