# v-ellipsis **Repository Path**: sun_yingbo/v-ellipsis ## Basic Information - **Project Name**: v-ellipsis - **Description**: Vue 3 文本省略组件,组件名为 VEllipsis,模板里写作 。内容超出容器时才弹出 Element Plus 的文字提示,未溢出时不显示气泡。 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-10-27 - **Last Updated**: 2026-10-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # v-overflow-ellipsis Vue 3 文本省略组件,组件名为 `VEllipsis`,模板里写作 ``。内容超出容器时才弹出 [Element Plus](https://element-plus.org/) 的文字提示,未溢出时不显示气泡。 只提供 ESM。 ## 安装 ```bash 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。 ```ts 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"); ``` ## 示例 ```vue ``` 不传 `content` 时,气泡文案取自默认插槽的文本。需要判断输入框、下拉框内部是否溢出时,设置 `measureSelector`: ```vue ``` 本地示例在 `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`,宽度跟父容器走。父容器需要有明确宽度,省略才会生效。 ## 本地开发 ```bash pnpm install pnpm dev pnpm build ``` `pnpm build` 产物在 `dist/`:`index.js`、`index.d.ts`、`style.css`。发布前会自动执行构建。 ## 许可 MIT