Filtered list

by ckissi

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>

  <div id="app">
        
    <input type="text" v-model="search">
    
    <div v-for="item in filteredItems" >
    <p>{{item.name}}</p>
    </div>
    
    
  </div>  

  <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.0.3/vue.js"></script>
  
</body>
</html>

CSS

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#app {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  transition: all 0.2s;
}

li {
  margin: 8px 0;
}

h2 {
  font-weight: bold;
  margin-bottom: 15px;
}

del {
  color: rgba(0, 0, 0, 0.3);
}

Vue

const app = new Vue({
  
  el: '#app',
  
  data: {
     search: '',
     items: [
       {name: 'Stackoverflow', type: 'development'},
       {name: 'Game of Thrones', type: 'serie'},
       {name: 'Jon Snow', type: 'actor'}
     ]
  },
  
  computed: {
    filteredItems() {
      return this.items.filter(item => {
         return (item.type.toLowerCase().indexOf(this.search.toLowerCase()) > -1 || item.name.toLowerCase().indexOf(this.search.toLowerCase()) > -1)
      })
    }
  }
  
})