Git Product home page Git Product logo

vue-overflow-ellipsis's Introduction

vue-overlow-ellipsis

原作者:https://github.com/wintc23/vue-overflow-ellipsis
将折叠逻辑整合到了组件内部。

Demo

https://q-jason.github.io/vue-overflow-ellipsis/docs/

在Vue项目中使用本组件

1. 安装

npm install vue-overflow-ellipsis-q

2. 在项目中引入组件以及依赖

<link rel="stylesheet" href="./dist/vue-overflow-ellipsis.css">
<script src="./dist/vue-overflow-ellipsis.js"></script>

or

import vueOverflowEllipsis from "vue-overflow-ellipsis-q"
import "vue-overflow-ellipsis-q/dist/vue-overflow-ellipsis.css"

3. 使用组件

<template>
  <!-- ... -->
    <vue-overflow-ellipsis :content="content"></vue-overflow-ellipsis>
  <!-- ... -->
</template>

4. API

说明:组件动态计算指定行数的容器能容纳的字符数量,动态截取字符串进行显示。组件内部使用ResizeObserver观察元素的size的变动并调用了refresh方法。但是IE不支持ResizeObserver,所以如果需要兼容IE动态

  • props

    • ellipsis 是否折叠,可以通过 .sync 双向绑定
    • content 文本字符串
    • rows 文本最大行数,默认是3
    • ellipsisText 省略号字符,默认是"..."
    • showMoreText 展开按钮的文字,默认是“展开”
    • hideMoreText 折叠按钮的文字,默认是“折叠”
    • btnShow 是否总是显示按钮,即便未超过最大行数,默认false
  • events

    • show-more 展开按钮点击事件
    • show-more 折叠按钮点击事件

源码运行

可以通过git将本项目clone到本地运行。

安装依赖

npm install

启动开发服务

npm run serve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.