Home >
front end > For help! Excuse me why delItem displays is not defined, this is not a built-in method, checkedItem
For help! Excuse me why delItem displays is not defined, this is not a built-in method, checkedItem
In classroom and online classes, netease cloud followed knocked on a piece of code, using the vue, introduced script tags, with net class is the same, but the console error delItem is not defined, how can I change?
<meta charset="utf-8" & gt;
Event & lt;/title>
<style>
- cloak [v]
{
display: none;
}
. List {width: 600 px; height: 25px; Margin - bottom: 10 px}
. The list. The active {background - color: aquamarine; Color: royalblue}
</style>
<body>
@ click="checkedItem (index)" & gt; . {{item name}} - & lt; The button type="button" @ click="delItem (index)" & gt; Delete & lt;/button>
<script SRC="https://cdn.jsdelivr.net/npm/vue@2.6.11" & gt; </script>
<script>
New Vue ({
El: "# app,"
Data ()
{
Return {
The list:
{id: 1, name: "zhang", the age: 28, active: false},
{id: 2, name: "bill", the age: 18, active: false},
{id: 3, name: "detective", the age: 38, active: false}
]
}
},
Methods: {
CheckedItem (index)
{
//the console. The log (index);
Enclosing a list [index]. Active=! Enclosing a list [index]. Active;
}
},
DelItem (index) {
Enclosing a list. The splice (index, 1);
}
}
)
</script>