父组件访问子组件里面的方法进行传参
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利
我有个父组件里面要进行一个方法,但是方法是在子组件里面,这个参数是子组件里面列表循环出来得到的id 我父组组件里面监控到了子组件的方法了,但是这个参数怎么传进去呢,父组件怎么拿到子组件里面列表循环出来的iD? 父组件 <mu-raised-button label=“下一步” class=“demo-raised-button fixed fullHeight” primary fullWidth backgroundColor="#FF4E4E" @click=“choseadd()”/> 父组件方法(暂时这个父组件的传参我是写死的是个5) choseadd() { this.$refs.choseadd.SelectAdd(5) }
父组件列表,我这里是要得到这个maddress.id这个进行传参
{{maddress.id}}
<mu-flexbox class="mt8" >
<mu-flexbox-item class="flex-demo">
{{maddress.consignee}}
</mu-flexbox-item>
<mu-flexbox-item class="flex-demo" style="text-align:right">
{{maddress.phone}}
</mu-flexbox-item>
</mu-flexbox>
<mu-flexbox class="mt8" orient="vertical">
<mu-flexbox-item order="0" class="flex-demo" >
[默认地址]{{maddress.area.long_label.join('')}}{{maddress.address}}
</mu-flexbox-item>
</mu-flexbox>
<mu-flexbox class="mt8 border-top" v-if="!$route.meta.edit">
<mu-flexbox-item class="flex-demo">
<mu-radio label="选择地址" name="group" class="demo-radio" [@change](/user/change)="switchIsCurrent(maddress.id)" :value="''+maddress.is_current" [@input](/user/input)="val=>{maddress.is_current=+val}" nativeValue="1" uncheckIcon="panorama_fish_eye" checkedIcon="check_circle" />
</mu-flexbox-item>
</mu-flexbox>
<mu-flexbox class="mt8 border-top" v-if="$route.meta.edit">
<mu-flexbox-item class="flex-demo">
<mu-radio label="默认地址" name="group" class="demo-radio" [@change](/user/change)="switchIsCurrent(maddress.id)" :value="''+maddress.is_current" [@input](/user/input)="val=>{maddress.is_current=+val}" nativeValue="1" uncheckIcon="panorama_fish_eye" checkedIcon="check_circle" />
</mu-flexbox-item>
<mu-flexbox-item class="flex-demo" style="text-align:right">
<mu-flat-button label="删除" class="demo-flat-button" icon="delete_sweep" [@click](/user/click)="deleteOpen(i)" v-if="maddress.is_current == 0"/>
<mu-flat-button label="编辑" class="demo-flat-button" icon="border_color" [@click](/user/click)="editOpen(i)"/>
</mu-flexbox-item>
</mu-flexbox>
<mu-dialog :open="maddress.dialog" title="提示" [@click](/user/click)="close(i)" >
是否确认删除此地址
<mu-flat-button slot="actions" [@click](/user/click)="deleteClose(i)" primary label="取消"/>
<mu-flat-button slot="actions" primary [@click](/user/click)="deleteAddress(maddress.id)" label="确定"/>
</mu-dialog>
</div>
子组件里面 的事件方法 SelectAdd(i) { Order.continue({type:‘user/address’, id:i}).then( ()=> {
} ).catch( () =>{
});
},