pespantelis / vue-typeahead

:mag: Typeahead component for Vue.js
http://pespantelis.github.io/vue-typeahead
MIT License
517 stars 97 forks source link

onHit(item) ... item undefined #42

Closed jonkristian closed 7 years ago

jonkristian commented 7 years ago

Hello. I'm using Vue 2 and I get undefined for item in onHit(item).

Also pulling in your demo Typeahead.vue returns undefined.

My package.json:

{
  "private": true,
  "scripts": {
    "prod": "gulp --production",
    "dev": "gulp watch"
  },
  "devDependencies": {
    "bootstrap-sass": "^3.3.7",
    "gulp": "^3.9.1",
    "jquery": "^3.1.0",
    "laravel-elixir": "^6.0.0-9",
    "laravel-elixir-vue-2": "^0.2.0",
    "laravel-elixir-webpack-official": "^1.0.2",
    "lodash": "^4.16.2",
    "vue": "^2.0.1",
    "vue-resource": "^1.0.3"
  },
  "dependencies": {
    "typeahead.js": "^0.11.1",
    "vue-typeahead": "^2.3.0"
  }
}
jonkristian commented 7 years ago

Using keys and enter seems to work, but not mousedown it seems.

uamana commented 7 years ago

Hello, I have the same issue. You problem in this line of code: <li v-for="item in items" :class="activeClass($index)" @mousedown="hit" @mousemove="setActive($index)" Vue 2 does not have $index variable defined, so you must use this syntax: li v-for="(item, index) in items" :class="activeClass(index)" @mousedown="hit" @mousemove="setActive(index)"