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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@tanzhenxing/zx-skeleton-item

v1.0.3

Published

zx-skeleton-item 骨架屏组件

Downloads

12

Readme

zx-skeleton-item 骨架屏项组件

zx-skeleton-item是骨架屏的子组件,用于构建不同形状和大小的骨架占位元素,通常与zx-skeleton组件配合使用,用于内容加载时显示的占位图形。

使用方法

基础用法

<template>
  <zx-skeleton-item variant="text" />
  <zx-skeleton-item variant="circle" :size="40" />
  <zx-skeleton-item variant="rect" :width="120" :height="40" />
</template>

<script setup>
import ZxSkeletonItem from '@/components/zx-skeleton-item/zx-skeleton-item.vue';
</script>

组合使用

通常与zx-skeleton组件配合使用:

<template>
  <zx-skeleton :loading="loading" animated>
    <template #template>
      <div style="display: flex; align-items: center;">
        <zx-skeleton-item variant="circle" :size="40" />
        <div style="margin-left: 12px;">
          <zx-skeleton-item variant="text" style="width: 200px; margin-bottom: 8px;" />
          <zx-skeleton-item variant="text" style="width: 150px;" />
        </div>
      </div>
    </template>
    
    <template #default>
      <div class="content">
        <!-- 实际内容 -->
      </div>
    </template>
  </zx-skeleton>
</template>

<script setup>
import { ref } from 'vue';
import ZxSkeleton from '@/components/zx-skeleton/zx-skeleton.vue';
import ZxSkeletonItem from '@/components/zx-skeleton-item/zx-skeleton-item.vue';

const loading = ref(true);

// 模拟数据加载
setTimeout(() => {
  loading.value = false;
}, 2000);
</script>

API

Props

| 参数 | 说明 | 类型 | 默认值 | |-----------|---------------------|-----------------------------------------------------|---------| | variant | 骨架屏的形状 | string: text / circle / rect / p / h1 / h3 / button / caption / image | text | | width | 宽度 | string / number | - | | height | 高度 | string / number | - | | size | 圆形骨架的大小,相当于同时设置width和height | string / number | - | | round | 是否为圆角 | boolean | false | | circle | 是否为圆形 | boolean | false | | active | 是否展示动画效果 | boolean | false |

内置类型(variant)

  • text: 文本行,默认样式
  • p: 段落,比text略高
  • h1: 大标题
  • h3: 小标题
  • caption: 说明文字
  • button: 按钮
  • image: 图片
  • circle: 圆形
  • rect: 矩形

样式自定义

组件支持通过style和class自定义样式:

<template>
  <zx-skeleton-item 
    variant="text" 
    style="width: 200px; margin-bottom: 8px;" 
    class="custom-skeleton-item"
  />
</template>

示例

不同形状组合

<template>
  <view class="skeleton-demo">
    <!-- 头像 + 文本 -->
    <view class="skeleton-item">
      <zx-skeleton-item variant="circle" :size="50" />
      <view class="skeleton-content">
        <zx-skeleton-item variant="h3" style="width: 150px; margin-bottom: 12px;" />
        <zx-skeleton-item variant="text" style="width: 240px;" />
      </view>
    </view>
    
    <!-- 图片 + 文本 -->
    <view class="skeleton-item">
      <zx-skeleton-item variant="image" :width="100" :height="100" />
      <view class="skeleton-content">
        <zx-skeleton-item variant="h3" style="width: 180px; margin-bottom: 12px;" />
        <zx-skeleton-item variant="text" style="width: 240px; margin-bottom: 8px;" />
        <zx-skeleton-item variant="text" style="width: 200px;" />
      </view>
    </view>
    
    <!-- 按钮 -->
    <view class="skeleton-item">
      <zx-skeleton-item variant="button" :width="120" :height="40" />
    </view>
  </view>
</template>

<style>
.skeleton-demo {
  padding: 20px;
}
.skeleton-item {
  display: flex;
  margin-bottom: 20px;
}
.skeleton-content {
  margin-left: 12px;
  flex: 1;
}
</style>

带动画效果

为骨架屏项添加动画效果,可以设置active属性:

<template>
  <zx-skeleton-item variant="text" :active="true" style="width: 200px;" />
</template>

兼容性

  • 支持H5、App以及各主流小程序平台
  • 低版本设备可能不支持部分动画效果