![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@kwai-explore/picture.vue
Advanced tools
用于展示多种图片格式的 picture 组件。
建议配合 (vite-plugin-image-presets) 使用
pnpm add -D vite-plugin-image-presets
vite.config.ts
import imagePresets, { formatPreset } from 'vite-plugin-image-presets';
// ...
plugins: [
vue(),
imagePresets({
modern: formatPreset({
formats: {
avif: {},
webp: {},
original: {},
},
loading: 'lazy',
}),
}),
],
添加类型:
vite-env.d.ts
declare module '*?preset=modern' {
const src: import('vue').ImgHTMLAttributes[];
// vue2.7 换成:
// const src: import('vue/types/jsx').ImgHTMLAttributes[];
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>
数据不能用插件生成时(比如接口种的数据),样例 src
属性是(注意顺序)
[{
type: 'image/webp',
srcset: '/assets/logo.ffc730c4.webp 48w, /assets/logo.1f874174.webp 96w',
},
{
type: 'image/jpeg',
srcset: '/assets/logo.063759b1.jpeg 48w, /assets/logo.81d93491.jpeg 96w',
src: '/assets/logo.81d93491.jpeg',
class: 'img thumb',
loading: 'lazy',
]
开发环境(vite dev
) 初次请求图片资源时需要进行格式转换,图片的加载时间比较长。
生产环境(vite build
) 会把需要的图片格式都构建出来。
vue >= 2.7
FAQs
用于配合图片压缩插件,展示多种图片格式的 Picture 组件。
The npm package @kwai-explore/picture.vue receives a total of 23 weekly downloads. As such, @kwai-explore/picture.vue popularity was classified as not popular.
We found that @kwai-explore/picture.vue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.