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

happypreview

v1.2.1

Published

view picture, support vue2.x

Downloads

1

Readme

happypreview

一个网页端的图片预览插件,支持vue2.x

安装

npm install happypreview

在Vue中使用

引入

import happypreview from 'happypreview'; Vue.use(happypreview);

方式一:通过标签的方式进行使用

  // 第一组
  <div class="first-group">
    <img big="xx.jpg" src="xx.jpg" alt="Image description" previewId="1" previewTitle="图片1" />
    <img big="xx.jpg" src="xx.jpg" alt="Image description" previewId="1" previewTitle="图片2" />
  </div>

  // 第二组
  <div class="second-group">
    <img big="xx.jpg" src="xx.jpg" alt="Image description" previewId="2" previewTitle="图片1" />
    <img big="xx.jpg" src="xx.jpg" alt="Image description" previewId="2" previewTitle="图片2" />
  </div>
  1. previewId 相同的 img 标签会作为同一组进行显示;
  2. big 是预览时的显示地址,通常是大图的地址,如果没有传入这个属性,那么默认将是 src 的属性;
  3. previewTitle 设置预览时的描述;

方式二:通过注册的方式使用

<template>
  <div class="hello">
    <button @click="handleBtn">显示图片</button>
  </div>
</template>

<script>
export default {
  methods: {
    handleBtn() {
      this.$happypreview({
        images: [
          "https://farm3.staticflickr.com/2567/5697107145_a4c2eaa0cd_o.jpg",
          "https://farm2.staticflickr.com/1043/5186867718_06b2e9e551_b.jpg",
          "https://farm7.staticflickr.com/6175/6176698785_7dee72237e_b.jpg"
        ],
        start: 0
      });
    }
  }
};

this.$happypreview() 支持传入两种类型的参数,一种是只包含src路径的数组[],例如:

this.$happypreview(['xxx.jpg', 'xxx1.jpg']);

另外一种方式是可以传入一个带有 images 和 start 属性的对象,start 属性用来标记默认显示的图片对应的索引,例如:

this.$happypreview({
  images: ["xxx.jpg", "xxx1.jpg", "xxx2.jpg"],
  start: 0
})

更新日志

2019/20/27

完成vue2.x的预览功能