亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

子組件觸發父組件的自定義事件 父組件無任何反應

子組件觸發父組件的自定義事件 父組件無任何反應

眼眸繁星 2018-11-14 18:27:50
以下為子組件 @change='showChange'為子組件事件以下模板注冊為 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) 并未執行
查看完整描述

1 回答

?
Smart貓小萌

TA貢獻1911條經驗 獲得超7個贊

你直接這么寫有問題的吧
應該是

<order-type @showChange='alertFun'></order-type>     

父組件有一個方法

methods: {

    alertFun () {

        alert(2)

    }

}

這里應該傳遞的是父組件方法的一個函數名,而不是直接寫alert(2)

查看完整回答
反對 回復 2018-12-15
  • 1 回答
  • 0 關注
  • 1021 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號