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

vue-wx-screenshot

v1.0.2

Published

模仿IOS微信的一个vue的截图插件,该插件只要提供一个图片地址,可以完成图片的旋转,平移,缩放(暂未实现),压缩,点击完成按钮后直接将改动后的图片以base64的形式返回,使用简单,轻量,无其他业务的绑定

Downloads

8

Readme

vue-wx-screenshot

模仿IOS微信的一个vue的截图插件,该插件只要提供一个图片地址,可以完成图片的旋转,平移,缩放(暂未实现),压缩,点击完成按钮后直接将改动后的图片以base64的形式返回,使用简单,轻量,无其他业务的绑定

安装

执行npm i vue-wx-screenshot -S

引入

<Crop
  :height="340"
  :width="340"
  ref="crop"
  @cancel="cancel"
  @finish="finish" />
import { crop } from 'vue-wx-screenshot'
export default {
  name: 'App',
  components: {
    Crop: crop
  }
}

事件

方法

该组件提供一个方法来打开截图组件

this.$refs.crop.open(imgUrl)
// 需要将该组件绑到父组件的ref中,将图片的url作为参数,
// 最好为本地图片转换成的base64地址,否则会出现跨域问题(canvas.toDataURL导致的)

使用案例

模板部分

<template>
  <div>
    <h1>请上传你要裁剪的图片</h1>
    <a class="btn" @click="upload">上传</a>
    <input type="file" @change="fileChange" ref="file" style="display: none;">

    <Crop
      :height="340"
      :width="340"
      ref="crop"
      @cancel="cancel"
      @finish="finish" />

    <img v-if="base64" :src="base64" alt="">
  </div>
</template>

js部分

  import { crop } from 'vue-wx-screenshot'
  export default {
    name: 'App',
    components: {
      Crop: crop
    },
    data () {
      return  {
        url: '',
        base64: ''
      }
    },
    methods: {
      /** 点击开始裁剪按钮,调出裁剪器 */
      upload () {
        this.$refs.file.click()
      },
      fileChange () {
        let file = this.$refs.file.files[0]
        let reader = new FileReader()
        reader.readAsDataURL(file)
        reader.onload = () => {
          this.$refs.file.value = ''
          this.$refs.crop.open(reader.result)
        }
      },
      /** 裁剪器取消事件 */
      cancel () {
        console.log('你取消了裁剪器')
      },
      /** 裁剪器的完成事件 返回了base64图片 */
      finish (base64) {
        this.base64 = base64
      }
    }
  }