每次點擊的時候讓對應的年齡+1這個年齡的值來自于父組件的數(shù)據(jù)這個+1的操作應該是在子組件還是寫在父組件里面(+1的操作不寫在標簽內(nèi)寫在父組件或者子組件內(nèi)可以嗎?)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]}}
vue子組件怎么操作父組件的數(shù)據(jù)?
達令說
2019-05-12 15:23:56