[Vuejs]-Dynamically set v-for with vue.js

2👍

You can just use a variable in your v-for attribute:

v-for item in items | filterBy id in 'id'

var vm = new Vue({
  ...
  data:function() {
    return {
      id:1
    }
  }
}

Then you could use v-model on an input like text or select, and set the id there:

<input v-model="id"> <!-- Filter to the id inputted here  -->

A few examples here: https://vuejs.org/api/#filterBy

👤Jeff

Leave a comment