TonPC64 / vue-highlight-text

🔦 Vue component for highlight multiple instances of a word

Home Page:http://vue-highlight-text.surge.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vue-highlight-text

NPM version NPM downloads Build Status

Vue component for highlight multiple instances of a word

Installation

# with yarn
yarn add vue-highlight-text

# with npm
npm install --save vue-highlight-text

Use component

import Vue from 'vue';
import HighlightText from 'vue-highlight-text';

Vue.component('HighlightText', HighlightText);

Use directive

import Vue from 'vue';
import highlight from 'vue-highlight-text/public/directive.min.js';

Vue.directive('highlight', highlight);

In file vue

<!-- component -->
<HighlightText :keyword="keyword" :sensitive="sensitive">{{msg}}</HighlightText>
<!-- Directive -->
<span v-highlight="{keyword: keyword}">{{msg}}</span>

Props or value of directive

Name Type Default Description
keyword string '' word for highlight in message.
sensitive bool true highlight with case sensitive
overWriteStyle Object {color: '#00C1E8'} custom highlight for overwrite style by HTML DOM Style Object

About

🔦 Vue component for highlight multiple instances of a word

http://vue-highlight-text.surge.sh

License:MIT License


Languages

Language:Vue 58.4%Language:JavaScript 40.3%Language:HTML 1.3%