1.0.4 • Published 6 years ago

vue-text-ellipsis v1.0.4

Weekly downloads
18
License
ISC
Repository
github
Last release
6 years ago

text-ellipsis

a text-ellipsis plugin both with Vue.

Intro

The situation when you need text ellipsis more then one line and the browser doesn't support the css style -webkit-line-clamp.

Install

npm install --save-dev vue-text-ellipsis

Link

If you are using without Vue, use the package with dom-based situation.dom-text-ellipsis instead.

Usage

import vue-text-ellipsis from 'vue-text-ellipsis';

vue.use(vue-text-ellipsis, {
    width: '50px',
    lineNum: 2,
    fontFamily: 'microsoft yahei',
    fontWeight: 'bold',
    fontSize: '14px',
    left: '...',
    tagName: 'p',
    isImmediate: true,
});

add the vue element in your .vue.

ellipsis(text="这是一句很长的话,真的很长很长很长,到底有多长呢,你来猜猜看" :line-num="2" tagName="p" :fontWeight="100" fontSize="16px" :left="left" :isImmediate="false")

Config

You can add config when vue.use to set global-config or use the props on vue elempent.

Property

PropsTypeDefaultEffect
widthStringThe parentsElement's offsetWidth.The max width for one line.
lineNumNumber2 (from global config)The max line.
fontFamilyStringmicrosoft yahei (from global config)The fontFamily to calculate the width.
fontSizeString| Number14px (from global config)The fontSize to calculate the width.
tagNameStringp (from global config)The tag to show the text.(only span p li )
leftString'…' (from global config)The String add on the end of the last line.
isImmediateBooleantrue (from global config)Update the text when the width change immediate or not(like debounce).

Methods

MethodsArgsEffect
updateRecalculate and update the text.
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.0

6 years ago