Vuejs Simple Input Autocomplete Select using JSON

In this Post We Will Explain About is Vuejs Simple Input Autocomplete Select using JSON With Example and Demo.

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Vuejs And Typeahead Auto Complete textbox Example

In this post we will show you Best way to implement Create your first component autocomplete with vueJS, hear for How to Vue.component AutoComplete with Dynamic Options with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.A vue.js typeahead and autocomplete component

READ :  vuejs time picker Example - vuejs-time-picker Demo - Vue Timepicker

Properties : Vuejs And Typeahead Auto Complete

value: String – The simple value HTML input field;
classes: String – The name of simple class for HTML input field
suggestionTemplate: String – A simple Custom template some which will be more displayed as more suggestion list
defaultSuggestion : Boolean – simple ‘true’ if you want to enable simple default more suggestion on data focus.
local: Array – If you want to simple pass your new existing data for more simple auto-completion items.
remote: String – The remote(server) url to fetch simple auto-completion Search items.
responseWrapper:Data String – The key name simple which is used call to wrap the response.

READ :  AngularJS Custom Service Factory with Example

index.html

using string simple template here to work using angularjs around HTML “option” placement simple restriction

<div id="liveApp"></div>
<script type="text/x-template" id="demo-template">
  <div>
    <p>Selected: {{ lastselected }}</p>
    <select2 :options="options" v-model="lastselected">
      <option disabled value="0">Select one</option>
    </select2>
  </div>
</script>

<script type="text/x-template" id="select2-template">
  <select>
    <slot></slot>
  </select>
</script>

index.js

Vue.component('select2', {
  props: ['options', 'value'],
  template: '#select2-template',
  mounted: function () {
    var vm = this
    $(this.$liveApp)
      .val(this.value)
      .select2({ data: this.options })
      .on('change', function () {
        vm.$emit('input', this.value)
      })
  },
  watch: {
    value: function (value) {
      $(this.$liveApp).select2('val', value)
    },
    options: function (options) {
      $(this.$liveApp).select2({ data: options })
    }
  },
  destroyed: function () {
    $(this.$liveApp).off().select2('destroy')
  }
})

var vm = new Vue({
  liveApp: '#liveApp',
  template: '#demo-template',
  data: {
    lastselected: 0,
    options: [
      { id: 1, text: 'Hello' },
      { id: 2, text: 'World' }
    ]
  }
})

Style.css

html, body {
  font: 13px/18px sans-serif;
}
select {
  min-width: 300px;
}

Example

READ :  vue autocomplete text input example - vuejs-autocomplete textbox

I hope you have Got Vue Select – VueJS Select2 Component And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.