每次点击的时候让对应的年龄+1这个年龄的值来自于父组件的数据这个+1的操作应该是在子组件还是写在父组件里面(+1的操作不写在标签内写在父组件或者子组件内可以吗?) li{display:inline-block;border:1pxsolidblack;width:100px} window.onload=function(){varcontents={template:'#contents',props:['age'],data(){return{arr:[{name:'zhangsan'},{name:'lisi'},{name:'wangwu'},]}},methods:{change(num){returnnum++;//这样不行}}}newVue({el:'#div1',data:{arr2:[43,55,20],},components:{'contents':contents},})}{{item.name}}{{age[index]}}
相关分类