All Projects → mizuka-wu → vue2-typeahead

mizuka-wu / vue2-typeahead

Licence: MIT License
A vue component of typeahead

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to vue2-typeahead

v-clappr
👏🏻Vue.js wrapper for Clappr media player
Stars: ✭ 18 (-47.06%)
Mutual labels:  vue2
blog-frontend
前后端分离实践----基于Vue2.js框架博客前端
Stars: ✭ 32 (-5.88%)
Mutual labels:  vue2
element-ui-saas-extend
基于ElementUI开发的SaaS业务扩展
Stars: ✭ 14 (-58.82%)
Mutual labels:  vue2
bpit-vue
vue effects component package 🚀
Stars: ✭ 16 (-52.94%)
Mutual labels:  vue2
huobi-PC
火币桌面客户端,基于electorn-vue开发
Stars: ✭ 56 (+64.71%)
Mutual labels:  vue2
v-pip
🖼 Tiny vue wrapper for supporting native picture-in-picture mode.
Stars: ✭ 30 (-11.76%)
Mutual labels:  vue2
hoc-element-table
📦 A Vue 3.x Table Component built on Webpack 5
Stars: ✭ 26 (-23.53%)
Mutual labels:  vue2
vue-viewload
vue图片懒加载lazyload,依赖vue2.0以上版本。支持图片或者其他资源进入可视区域后加载。
Stars: ✭ 77 (+126.47%)
Mutual labels:  vue2
vue
Vue.js Demos. jQWidgets Vue.js Components - Grids, Charts, Scheduling, Pivot Tables
Stars: ✭ 55 (+61.76%)
Mutual labels:  vue2
vue2-animate
A port of Animate.css for use with transitions in Vue.js 2.0 / 3.0 and Alpine.js.
Stars: ✭ 1,338 (+3835.29%)
Mutual labels:  vue2
Code-VueWapDemo
“Vue教程--Wap端项目搭建从0到1”的源码
Stars: ✭ 19 (-44.12%)
Mutual labels:  vue2
purescript-halogen-select
Building blocks for common selection user interfaces in PureScript & Halogen
Stars: ✭ 62 (+82.35%)
Mutual labels:  typeahead
ngx-typeahead
Typeahead multi-select dropdown component for angular. Demo:
Stars: ✭ 22 (-35.29%)
Mutual labels:  typeahead
vue-snippets
Visual Studio Code Syntax Highlighting For Vue3 And Vue2
Stars: ✭ 25 (-26.47%)
Mutual labels:  vue2
ng-sq-ui
Flexible and easily customizable UI-kit for Angular 11+
Stars: ✭ 99 (+191.18%)
Mutual labels:  typeahead
vue-timeline
a timeline for vue2 and bootstrap3
Stars: ✭ 59 (+73.53%)
Mutual labels:  vue2
v-currency
A plugin for formatting currency for different countries in Vue
Stars: ✭ 24 (-29.41%)
Mutual labels:  vue2
vue-single-select
single select dropdown with autocomplete
Stars: ✭ 43 (+26.47%)
Mutual labels:  typeahead
office-fabric
johannes-z.github.io/office-fabric/
Stars: ✭ 12 (-64.71%)
Mutual labels:  vue2
vue-thailand-address
🇹🇭 Thai address input for Vue.
Stars: ✭ 44 (+29.41%)
Mutual labels:  typeahead

vue2-typeahead

typeahead for vue2
Based onhttps://github.com/pespantelis/vue-typeahead

publish to npm upload release asset

Quick preview

demo Demo

Run demo

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

Warning

Prepared rewrite by vue2.5 and bootstrap 4

How to use

  1. Please install axios
  2. It base on bootstrap css
  3. npm install vue2-typeahead --save
  4. import and use it import TypeAhead from 'vue2-typeahead' or import TypeAhead from 'vue2-typeahead/src/components/TypeAhead.vue'
  5. config (you can get a config sample from Demo.vue)

Sample

 <TypeAhead
      src="https://github.com/static/data.json?keyword=:keyword"
      :getResponse="getResponse"
    ></TypeAhead>

methods: {
      getResponse: function (response) {
        return response.data.items
      }
    }

Config props

v-model

You can get the result by set v-model="" attribute

Necessary

  1. src: The api url for get the data
  2. getResponse: The function to get a array form response

Optional

  1. selectFirst default:false auto select first item
  2. queryParamName default::keyword this will be replace to what you input in ajax request
  3. limit default:9999 how many items will show in the list
  4. minChars default:2 only words length large than this number can emit the request
  5. delayTime default:500 delay time for emit the request for avoiding request when inputing
  6. placeholder default:null placeholder
  7. classes default:null the class you want add to input component
  8. onHit default:Function how to use the things you hit
  9. highlighting default:Function highlighting every item
  10. render default:Function to render the lists which will be show
  11. fetch default:Function how to send the url

other

other attribute will bind on <input /> like disabled on v1.3.0

What you can get in instance

Some function will return vue object, it is the instance of component and i use it to change the query, you can also get some useful data by it

  1. items: option list after render function
  2. current: current id is select or cursor is hover
  3. data: the response data of fetch

A Complete Config Sample

<TypeAhead
      v-model="data"
      :classes="classes"
      :placeholder="placeholder"
      src="https://github.com/static/data.json?keyword=:keyword"
      :getResponse="getResponse"
      :selectFirst="selectFirst"
      :limit="parseInt(limit)"
      :queryParamName="queryParamName"
      :minChars="parseInt(minChars)"
      :delayTime="parseInt(delayTime)"
      :onHit="onHit"
      :highlighting="highlighting"
      :render="render"
      :fetch="fetch"
    ></TypeAhead>
    data () {
      return {
        data: '',
        selectFirst: false,
        limit: 9999,
        queryParamName: ':keyword',
        minChars: 2,
        delayTime: 500,
        placeholder: 'Please input something',
        classes: 'typeahead'
      }
    },
    methods: {
      getResponse: function (response) {
        return response.data.data.items
      },
      onHit: function (item, vue, index) {
        vue.query = item
      },
      highlighting: function (item, vue) {
        return item.toString().replace(vue.query, `<b>${vue.query}</b>`)
      },
      render: function (items, vue) {
        // 将搜索内容作为list的第一个
        let newItem = [vue.query, ...items]
        return newItem
      },
      fetch: function (url) {
        return axios.get(url)
      }
    },
    components: {
      TypeAhead
    }

License

vue2-typeahead is released under the MIT License. See the bundled LICENSE file for details.

donate

donate

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].