Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aidol/image

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aidol/image

A image component for vue

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

aidol-image

A image Component for vue

Installation

$ npm i @aidol/image --save

Usage

<!-- demo.vue -->

<template>
<div>
  <ai-image :src="url" :preview-src-list="srcList" viewer-tips="hello aidol image" @switch="handleSwitch" />
</div>
</template>
import AiImage from '@aidol/image'
export default {
  components: {
    AiImage
  },
  data() {
    return {
      url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      srcList: [
        'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ]
    }
  },
  methods: {
    handleSwitch(index, viewer) {
      console.log(index) // 当前预览图索引
      console.log(viewer) // 大图预览组件实例
    }
  }
}

Attributes

参数说明类型可选值默认值
src图片源,同原生string--
fit确定图片如何适应容器框,同原生 object-fitstringfill / contain / cover / none / scale-down-
alt原生 altstring--
referrer-policy原生 referrerPolicystring--
lazy是否开启懒加载boolean-false
scroll-container开启懒加载后,监听 scroll 事件的容器string / HTMLElement-最近一个 overflow 值为 autoscroll 的父元素
z-index设置图片预览的 z-indexNumber-2000
viewer-tips为当前大图预览提供的提示文本内容,如果提供了,则会显示在预览弹出层的上方,默认文本居中。如果是 string 类型,则每张预览大图显示同样的提示文本,如果是 function 类型,则该函数会被依次传入 index 当前预览大图索引值,viewer 大图预览组件实例。string / function-undefined
viewer-tips-class-nameviewer-tips 元素添加类名string-ai-image-viewer__tips
viewer-tips-styleviewer-tips 元素添加样式object-见下方注释

viewer-tips-style默认值:

{
  height: '40px',
  width: '100%',
  display: 'flex',
  justifyContent: 'center',
  alignItems: 'center',
  fontSize: '12px',
  color: '#ccc',
  position: 'absolute',
  left: '0px',
  top: '0px'
}

Events

事件名称说明回调参数
load图片加载成功触发(e: Event)
error图片加载失败触发(e: Event)
switch预览图切换时触发,首次点开预览图时也会触发。index 当前预览图索引值,viewer 大图预览弹出层组件实例。(index: number, viewer: VNode)

Slots

名称说明
placeholder图片未加载的占位内容
error加载失败的内容

Keywords

FAQs

Package last updated on 06 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc