New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@kwai-explore/picture

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kwai-explore/picture

用于展示多种图片格式的 picture 组件。

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-62.5%
Maintainers
2
Weekly downloads
 
Created
Source

@kwai-explore/picture

用于展示多种图片格式的 picture 组件。

使用

建议配合 (vite-plugin-image-presets) 使用

安装 vite-plugin-image-presets

pnpm add -D vite-plugin-image-presets

建议配置

vite.config.ts

 plugins: [
   vue(),
   imagePresets({
     modern: formatPreset({
       formats: {
         avif: {},
         webp: {},
         original: {},
       },
       loading: 'lazy',
     }),
   }),
 ],

添加类型:

vite-env.d.ts

declare module '*?preset=modern' {
 const src: import('vite-plugin-image-presets').ImageAttrs[];
 export default src;
}

安装依赖

pnpm add @kwai-explore/picture

在代码中使用

Picture 组件接受的属性跟 img 相同

<script setup lang="ts">
import Picture from '@kwai-explore/picture';
import examplePic from './components/example.jpg?preset=modern';
</script>

<template>
  <Picture :src="examplePic"></Picture>
</template>

对应的行为

开发环境(vite dev) 初次请求图片资源时需要进行格式转换,图片的加载时间比较长。

生产环境(vite build) 会把需要的图片格式都构建出来。

兼容性

vue >= 2.7

FAQs

Package last updated on 16 Oct 2022

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