0.0.3 • Published 6 years ago

v-mai-keyword-highlight v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

v-mai-keyword-highlight

A plugin for Vue.js 2 that highlight the keywords. Check out the demo.

Installation

  • NPM Run npm install --save v-mai-keyword-highlight

  • With Modules

// ES6
import Vue from 'vue'
import vMaiPlugins from 'v-mai-keyword-highlight'
Vue.use(vMaiPlugins.vMaiKeywordHighlight)

// ES5
var Vue = require('vue')
Vue.use(require('v-mai-keyword-highlight')[0])
  • <script> Include

Just include ./dist/v-mai-keyword-highlight.js after Vue itself.

Usage

v-mai-keyword-highlight is one custom directive, so the usage is like below

<div v-mai-keyword-highlight="{keyword:keyword, 'style':'background-color:'+style, 'callback':getKeywordPosition, 'delay':500, key: 1}">
  <p>I am a test 1.</p>
  <p>I am a test 2.</p>
</div>

Custom Configurations

NameTypeValue
keywordStringThe keyword you'd like to search
styleStringThe style applied to the keyword, like 'background-color:red'
callbackFunctionThe directive will run this callback with one parameter = All positions of th keywords already found out like {'top':0, 'left': 1}
delayNumberdelay how many milliseconds to execute the search
keyNumber or StringYou'd better to pass one unique key
multipleBooleanMatch multiple keywords or not
match-caseBooleanCase-sensitive or not

License

MIT