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

@kiko-yd/vue-show-more

v0.0.1-beta.2

Published

A lightweight Vue 3 component for expanding/collapsing long text content

Downloads

136

Readme

Vue Show More

一个轻量级的 Vue 3 组件,用于处理多行文本的展开/收起功能。

特性

  • 🎯 支持自定义展开行数
  • 🎨 支持通过插槽自定义展开/收起按钮
  • 📱 响应式设计,支持移动端
  • ⚡ 零依赖,轻量级
  • 💪 使用 Vue 3 + TypeScript 开发,提供完整类型支持
  • 🎈 灵活的按钮位置:支持内联和底部两种样式

安装

npm install @kiko-yd/vue-show-more
# 或
yarn add @kiko-yd/vue-show-more

使用方法

基础用法

<template>
  <ShowMore
    :max-lines="3"
    expand-text="展开"
    collapse-text="收起"
    @expand="onExpand"
  >
    这是一段很长的文本...
  </ShowMore>
</template>

<script setup lang="ts">
import { ShowMore } from "vue-show-more";
</script>

内联按钮样式

<template>
  <ShowMore
    :max-lines="3"
    action-position="inline"
    expand-text="展开"
    collapse-text="收起"
    mask-background="#f5f5f5"
  >
    <p style="font-size: 18px">这是一段很长的文本...</p>
  </ShowMore>
</template>

自定义展开/收起按钮

<template>
  <ShowMore :max-lines="3">
    <div style="font-size: 16px">这是一段很长的文本...</div>
    <template #action="{ isExpanded }">
      <button class="custom-button">
        {{ isExpanded ? "收起" : "查看更多" }}
        <icon-arrow :direction="isExpanded ? 'up' : 'down'" />
      </button>
    </template>
  </ShowMore>
</template>

Props

| 属性 | 类型 | 默认值 | 描述 | | ----------------- | -------------------- | -------- | --------------------------------------------------------------------------------- | | maxLines | number | 3 | 收起状态下显示的最大行数 | | expandText | string | "展开" | 展开按钮的文本 | | collapseText | string | "收起" | 收起按钮的文本 | | class | string | - | 自定义样式类名 | | expandButtonClass | string | - | 展开按钮的自定义样式类名 | | actionPosition | 'inline' | 'bottom' | 'bottom' | 展开/收起按钮的位置。'inline' 表示按钮跟随在文本末尾,'bottom' 表示按钮在新行显示 | | maskBackground | string | 'white' | 内联模式下的背景色,用于遮罩层和按钮背景,应与容器背景色保持一致 |

插槽

default

默认插槽,用于传入需要展开/收起的内容。默认按钮会自动继承该内容的字体样式。

action

自定义展开/收起按钮的内容和样式

作用域参数

| 参数名 | 类型 | 说明 | | ------------ | ------- | ------------ | | isExpanded | boolean | 当前是否展开 | | expandText | string | 展开按钮文本 | | collapseText | string | 收起按钮文本 |

事件

| 事件名 | 参数 | 描述 | | ------ | ------------------- | ----------------------- | | expand | isExpanded: boolean | 展开/收起状态改变时触发 |

License

MIT