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

v-overflow-ellipsis

v0.1.0

Published

溢出时才显示提示的 Vue 3 文本省略组件

Readme

v-overflow-ellipsis

Vue 3 文本省略组件,组件名为 VEllipsis,模板里写作 <v-ellipsis>。内容超出容器时才弹出 Element Plus 的文字提示,未溢出时不显示气泡。

只提供 ESM。

安装

pnpm add v-overflow-ellipsis
pnpm add vue element-plus

vue 和 element-plus 是 peer 依赖,需要由使用方安装并注册。

| 依赖 | 版本 | | --- | --- | | vue | ^3.5.0 | | element-plus | ^2.11.0 |

注册

在应用入口注册 Element Plus,并单独引入本包样式。构建工具不会自动带上这份 CSS。

import { createApp } from "vue";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import "v-overflow-ellipsis/style.css";
import App from "./App.vue";

createApp(App).use(ElementPlus).mount("#app");

示例

<script setup lang="ts">
import { VEllipsis } from "v-overflow-ellipsis";
</script>

<template>
  <div style="width: 180px">
    <VEllipsis content="很长的标题" placement="top-start" :max-width="320" />
  </div>
</template>

不传 content 时,气泡文案取自默认插槽的文本。需要判断输入框、下拉框内部是否溢出时,设置 measureSelector:

<VEllipsis
  :content="name"
  measure-selector=".el-input__inner"
  :max-width="280"
>
  <el-input v-model="name" />
</VEllipsis>

本地示例在 playground/。仓库内执行 pnpm dev 后打开开发服务器即可查看。

属性

| 属性 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | content | string \| number \| null | — | 气泡文案。为空时使用插槽文本 | | placement | 同 el-tooltip | top-start | 气泡位置 | | effect | "light" \| "dark" | light | 气泡主题 | | tooltipClass | string | "" | 加到气泡上的类名 | | maxWidth | string \| number | "" | 气泡最大宽度。数字按 px 处理 | | measureSelector | string | "" | 用这个选择器测量内部元素是否溢出 | | enterable | boolean | 自动 | 鼠标能否移入气泡。不传时,触屏设备为 false |

根节点会透传 class 和原生事件。组件自身是一个 inline-block,宽度跟父容器走。父容器需要有明确宽度,省略才会生效。

本地开发

pnpm install
pnpm dev
pnpm build

pnpm build 产物在 dist/:index.js、index.d.ts、style.css。发布前会自动执行构建。

许可

MIT