Vue

by evzens

HTML

<div id="root">
<h2>
Jidlo
</h2>
<input v-model="newMeal" @keyup.enter="addMeal">
<button @click="addMeal">
Add 
</button>
<ul>
  <li v-for="cat in cats">{{ cat.text | capitalize | kitify}} </li>
</ul>

</div>

CSS

body {
  background: #20262E;
  padding: 20px;
}

#root {
  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

new Vue({
  el: "#root",
  data: {
    cats: [
      { text: "Mys" },
      { text: "Jablko" },
      { text: "Meloun" },
      { text: "Ryba" }
    ],
    newMeal: ''
  },
  methods: {
  	addMeal: function() {
       this.cats.push({ text: this.newMeal})
       this.newMeal = ''
    }
  },
  filters: {
  	capitalize: function(value) {
    	return value.toUpperCase()
    },
    kitify: function(value) {
    	return value + 'z'
    }
  }
})