each click, let the value of the corresponding age of + 1 come from the data of the parent component. Should the operation of + 1 be written in the child component or in the parent component (can the operation of + 1 not be written in the tag and written in the parent component or child component?)
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
li{display: inline-block;border: 1px solid black;width: 100px}
</style>
<script src="vue.js"></script>
<script type="text/javascript">
window.onload=function(){
var contents={
template:"-sharpcontents",
props:["age"],
data(){
return {
arr:[
{name:"zhangsan"},
{name:"lisi"},
{name:"wangwu"},
]
}
},
methods:{
change(num){
return numPP; //
}
}
}
new Vue({
el:"-sharpdiv1",
data:{
arr2:[43,55,20],
},
components:{
"contents":contents
},
})
}
</script>
</head>
<body>
<template id="contents">
<div>
<ul>
<li v-for="(item,index) in arr" @click=change(age[index])>{{item.name}}{{age[index]}}</li>
</ul>
</div>
</template>
<div id="div1">
<contents :age="arr2"></contents>
</div>
</body>
</html>