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

easy-preview

v1.0.7

Published

a vue plugin for preview website picture

Downloads

18

Readme

使用方法

注册

全局注册

1. npm install easy-preview
2. 在main.js中加入下面两句
    import EasyPreview from "easy-preview";
    Vue.use(EasyPreview);
3. 使用<EasyPreview>标签即可

局部注册

1. 使用npm install easy-preview安装插件
2. 在组件中注册EasyPreview
    import EasyPreview from "easy-preview";
    Vue.use(EasyPreview);
3. 使用<EasyPreview>;标签即可
import EasyPreview from "easy-preview";
export default {
  name: 'app',
  components: {EasyPreview},
  data () {
    return {}
  }
}

使用

控制权交给组件的使用

这种使用方式比较简单,只要传入一个img标签给插槽使用并传入img-src属性即可

<EasyPreview :img-src="imgSrc">
    <img :src="imgSrc" width="500" style="border-radius: 10px" alt="">
</EasyPreview>

控制权不交给组件的使用

这个时候要传入一个属性options,并将options.controlByUsers置为true,此时插槽会失效,需要传入一个额外的属性:show-preview控制显示和隐藏,此时点击右上角自带的关闭按钮改为触发自定义的clickCloseButton / click-close-button (两个都会触发)事件,可以监听事件并修改传入的show-preview的值。

<img :src="imgSrc" alt="" width="500" style="border-radius: 10px" @click="onclick">
<EasyPreview :img-src="imgSrc" :options="options" :show-preview="showPreview"   @clickCloseButton="onClickCloseButton"></EasyPreview>



{
    methods : { 
        onclick() {
            this.showPreview = true
        }
        onClickCloseButton() {
            this.showPreview = false;
        }
    }
}

说明文档

全部属性的含义

| 属性名 | 含义 | 默认值 | 备注 | | -------------------- | -------------------------------- | ------ | --------------------------------------------- | | imgSrc | 浏览时的图片链接 | "" | | | options | 自定义选项 | null | 具体参数看下面 | | showPreview | 是否展示预览图 | false | 仅控制权不是组件内部时生效 | | clickCloseButton | 点击关闭按钮时会触发的自定义事件 | | 仅控制权不是组件内部时生效 ,需要绑定回调函数 | | click-close-button | 点击关闭按钮时会触发的自定义事件 | | 仅控制权不是组件内部时生效 ,需要绑定回调函数 |

PS:clickCloseButton绑定的事件执行时会被传入一个函数,执行这个函数可以把图片恢复初始状态,调用时可以传入一个延迟执行的时间,这个时间默认是500ms(如果你没有修改transition的时间的话,最好不要修改它)

onClickCloseButton(reset) {
    this.showPreview = false;
    reset(500);
},

options的几个可选项

| 属性名 | 含义 | 默认值 | 备注 | | --------------------- | ------------------------------- | ------ | ------------------------------------------ | | controlByUsers | 控制权是否交给组件外部 | false | | | showCloseButton | 是否显示右上角的关闭按钮 | true | | | showStatusExtraStyle | 展示状态时额外的样式 | "" | 可以传入对象或者字符串,样式优先级为内联级 | | hideStatusExtraStyle | 隐藏状态时额外的样式 | "" | 可以传入对象或者字符串,样式优先级为内联级 | | buttonExtraStyle | 右上的按钮没有hover时的额外样式 | "" | 可以传入对象或者字符串,样式优先级为内联级 | | buttonHoverExtraStyle | 右上的按钮hover时的额外样式 | "" | 可以传入对象或者字符串,样式优先级为内联级 | | | | | |