s3e43 keeping track of elements when using v-for
This commit is contained in:
parent
a333938377
commit
1f9047ff09
@ -8,10 +8,12 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id='app'>
|
<div id='app'>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(ingredient, i) in ingredients">
|
<li v-for="(ingredient, i) in ingredients" :key="ingredient">
|
||||||
({{i+1}}) {{ ingredient }}
|
({{i+1}}) {{ ingredient }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<button @click="ingredients.push('spices')"> Add New</button>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
<template v-for="(ingredient, index) in ingredients">
|
<template v-for="(ingredient, index) in ingredients">
|
||||||
<h1>{{ingredient}}</h1>
|
<h1>{{ingredient}}</h1>
|
||||||
|
Loading…
Reference in New Issue
Block a user