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-image-pro

v1.4.5

Published

An Image Component for Vue.js | 一个Vue图片增强组件

Downloads

22

Readme

vue-image-pro

Build Status license npm size download codecov

English Document

English Document

介绍

组件的灵感来源于小程序的 image 组件vue-avatar 组件, 相当于同时拥有两者的特性, 实现了包括图片自适应、响应式、当无图片时显示文字等。

应用场景

典型的应用场景就是头像, 当有图片是显示图片, 当无图片时显示用户名

相对于 vue-avatar 的改进

  • 对中文友好
  • 当图片宽高不一致时, 依然可以完美显示, 不会变形

文档和示例

文档点我查看 在线示例点我查看

Installation 安装

npm install vue-image-pro  --save

Usage 用法

// 全局 (推荐)
import ImagePro from 'vue-image-pro'

// 可以配置全局默认值
Vue.use(ImagePro, {
  src: '',
  color: '',
  username: '',
  backgroundColor: '',
  size: '',
  width: '',
  height: '',
  radius: '',
  mode: ''
})
// 局部导入
// 这里注意要有 {} 括号
import { ImagePro } from 'vue-image-pro'

export default {
  ...
  components: {
    ImagePro
  },
  ...
}
<image-pro :size="100" username="vue-image-pro" background-color="#123456" />

Props

| 属性名 | 是否必填 | 默认值 | 类型 | 说明 | | --------------- | :------: | :-------------------------------: | ------ | ------------------------------------------------------------ | | username | N | (空字符) | String | 当 src 为空时,显示计算后用户名 | | src | N | - | String | 图片链接 | | defaultSrc | N | - | String | 默认图片 | | mode | N | aspectFill | String | 图片展示模式(下有详细介绍) | | size | N | 50 | Number | 宽=高=size 值, 如设置 width 和 height 属性, 会覆盖 size 属性 | | width | N | - | Number | 图片宽度 | | height | N | - | Number | 图片高度 | | color | N | 根据背景色自动计算 | String | 字体颜色 | | backgroundColor | N | 随机颜色 | String | 背景颜色 | | isShowBgColor | N | false | String | 当存在 src 时, 是否显示 backgroundColor 背景色 | | radius | N | 有图时默认为: 0, 无图时默认是: 50 | Number | 图片圆角 | | customStyle | N | {} | Object | 自定义样式 |

mode 值

| 值 | 说明 | | ----------- | ------------------------------------------------------------------------------------------------------------------------ | | aspectFill | 保持纵横比缩放图片,只保证图片的短边能完全显示出来。也就是说,图片通常只在水平或垂直方向是完整的,另一个方向将会发生截取 | | scaleToFill | 不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素 | | aspectFit | 保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来 | | widthFix | 宽度不变,高度自动变化,保持原图宽高比不变 | | heightFix | 高度不变,宽度自动变化,保持原图宽高比不变 |

支持插槽

<!-- 实例 -->
<image-pro>插槽</image-pro>

事件

| 事件名 | 说明 | | ------- | ------------ | | success | 图片加载成功 | | error | 图片加载失败 |