Vue
by laylatichy
HTML
<div id="app">
<div v-for="ship in shipList" :key="ship.text">
{{ship.text}}
<input type="number" min="0" placeholder="wpisz ilosc" v-model="ship.value" />
<button @click="addToCart(ship), parentElement">
Add to cart
</button>
</div>
</div>
CSS
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
Vue
new Vue({
el: "#app",
data: {
shipList: [
{ text: "ship1", value: '',},
{ text: "ship2", value: '', },
{ text: "ship3", value: '', },
{ text: "ship5", value: '', }
]
},
methods: {
addToCart: function(ship){
console.log(ship.text);
console.log(ship.value);
}
}
})