以下為子組件 @change='showChange'為子組件事件以下模板注冊(cè)為 order-type組件<template><select name="dType" class="form-control" v-el:select @change='showChange'> <option value="" v-if="type=='selectAll'">全部</option> <option v-for="branch in branchList" :value="branch.id" track-by="$index"> {{branch.name}} </option> </select></template>以下為子組件方法: showChange(event) { for (let branch of this.branchList) {
if (branch['id'] === event.target.value) { this.$emit('showChange',branch['prefix']);
}
}以下是父組件<order-type @showChange='alert(2)'></order-type>但alert(2) 并未執(zhí)行
子組件觸發(fā)父組件的自定義事件 父組件無任何反應(yīng)
眼眸繁星
2018-11-14 18:27:50