在子組件中(即ele-component組件):this.$emit('getAttrObj', this.attrObj),在父組件中:<ele-component v-for="(component,index) in componentArray" @getAttrObj="getAttrObj"></ele- component>methods: { getAttrObj (attrObj, index) {
}}那么父組件中可以拿到this.attrObj這個參數,然而除此之外還需要那個index來作為方法的參數(在對象在數組中的序號),雖說可以先傳給子組件,再讓子組件傳回來,不過感覺有點費勁。請問是否能夠直接在父組件中進行傳值而不覆蓋子組件傳上來的this.attrObj呢?(就是在父組件中將index傳入給getAttrObj方法)
vuejs的$emit如何在父組件中自己添加參數。
慕森卡
2018-10-19 14:11:22