mirror of
https://github.com/tenrok/vue-tribute.git
synced 2026-06-10 22:22:26 +03:00
53 lines
1.5 KiB
Markdown
53 lines
1.5 KiB
Markdown
# vue-tribute
|
|
|
|
[](https://travis-ci.org/syropian/vue-tribute)
|
|
|
|
> A Vue.js wrapper for Zurb's [Tribute](https://github.com/zurb/tribute) library for native @mentions.
|
|
|
|
## Install
|
|
|
|
```js
|
|
$ npm install vue-tribute --save
|
|
```
|
|
|
|
**or** include the UMD build, hosted by [npmcdn](https://npmcdn.com) in a `<script>` tag. You will also need to include the main Zurb Tribute library:
|
|
|
|
```js
|
|
<script src="js/tribute.js"></script>
|
|
<script src="//npmcdn.com/vue-tribute"></script>
|
|
```
|
|
|
|
## Usage
|
|
|
|
```js
|
|
import Vue from "vue";
|
|
import VueTribute from "vue-tribute";
|
|
|
|
Vue.use(VueTribute, options);
|
|
```
|
|
|
|
> The `options` parameter is optional.
|
|
|
|
...and inside your template, bind a dynamic `values` parameter to some data:
|
|
|
|
`<input type='text' :values='items' v-tribute />`
|
|
|
|
The `values` array should be an array of objects that contain a key and value like so:
|
|
|
|
```
|
|
[
|
|
{key: "Phil Heartman", value: "pheartman"},
|
|
{key: "Gordon Ramsey", value: "gramsey"}
|
|
]
|
|
```
|
|
|
|
You can modify this structure using the built-in [Tribute options](https://github.com/zurb/tribute#a-collection).
|
|
|
|
## Events
|
|
|
|
Tribute broadcasts two events — a `tribute-replaced` event, and a `tribute-no-match` event (see docs [here](https://github.com/zurb/tribute#replace-event)). For your convenience, whenever Tribute triggers these events, vue-tribute also [emits](http://vuejs.org/api/#vm-emit) these events from the Vue instance the bound element is attached to.
|
|
|
|
## License
|
|
|
|
MIT © [Collin Henderson](https://github.com/syropian)
|