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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tanzhenxing/zx-bg-image

v1.0.2

Published

一个支持背景图片显示的容器组件,图片显示在最底层,上层可以放置其他内容。

Readme

zx-bg-image 背景图组件

简介

一个支持背景图片显示的容器组件,图片显示在最底层,上层可以放置其他内容。

基本用法

<template>
  <zx-bg-image src="/static/bg.jpg" width="100vw" height="300px">
    <view style="padding: 20px; color: white;">
      <text>这里是内容区域</text>
    </view>
  </zx-bg-image>
</template>

Props

| 参数 | 类型 | 默认值 | 说明 | |------|------|--------|------| | src | String | '' | 背景图片地址 | | width | String/Number | '100vw' | 组件宽度 | | height | String/Number | 'auto' | 组件高度 | | mode | String | 'aspectFill' | 图片裁剪模式 | | minHeight | String/Number | '' | 最小高度 | | maxHeight | String/Number | '' | 最大高度 | | backgroundColor | String | '#f5f5f5' | 背景色(图片加载失败时显示) | | showLoading | Boolean | false | 是否显示加载状态 | | contentClass | String | '' | 内容区域样式类名 | | contentPadding | String/Number | '0' | 内容区域内边距 |

Events

| 事件名 | 说明 | 回调参数 | |--------|------|----------| | load | 图片加载成功时触发 | event | | error | 图片加载失败时触发 | event |

使用示例

基础用法

<zx-bg-image src="/static/banner.jpg">
  <view class="content">
    <text>内容区域</text>
  </view>
</zx-bg-image>

设置尺寸

<zx-bg-image 
  src="/static/bg.jpg" 
  width="375px" 
  height="200px"
  min-height="150px"
>
  <view>内容</view>
</zx-bg-image>

自定义内容样式

<zx-bg-image 
  src="/static/bg.jpg"
  content-padding="20px"
  content-class="custom-content"
>
  <view>带内边距的内容</view>
</zx-bg-image>

监听事件

<zx-bg-image 
  src="/static/bg.jpg"
  @load="onImageLoad"
  @error="onImageError"
>
  <view>内容</view>
</zx-bg-image>

注意事项

  1. 背景图片使用绝对定位,层级为 z-index: 1
  2. 内容区域层级为 z-index: 2,确保显示在背景图上方
  3. 当 height 设置为 'auto' 时,组件高度会根据内容自适应
  4. 支持所有 uni-app image 组件的 mode 属性值