javascript - vue中自定義事件如何傳遞參數(shù)?
問題描述
如代碼所示,在子組件中定義和觸發(fā)了select方法并將type參數(shù)傳入,在父組件中引入子組件,并監(jiān)聽select事件
結(jié)果報錯:“Property or method 'type' is not defined on the instance but referenced during render.” 是我傳遞參數(shù)的方法不對嗎?
//子組件<button type='button' name='button' v-bind: v-on:click='select(2,$event)'> {{desc.all}} <span class='count'>{{ratings.length}}</span></button><script type='text/ecmascript-6'> methods:{ select:function (type,event) {if (!event._constructed){ return;}this.$emit(’select’,type) }</script>
//父組件<rating-select v-bind='{ratings:food.ratings,selectType:selectType,onlyContent:onlyContent}' v-on:select='updSelect(type)' v-on:toggleContent='toggleContent' class='rating-select'></rating-select><script> updSelect:function (type) {this.selectType = type }</script>
問題解答
回答1:v-on:select='updSelect'
相關(guān)文章:
1. mysql數(shù)據(jù)庫做關(guān)聯(lián)一般用id還是用戶名2. javascript - 如何用最快的速度C#或Python開發(fā)一個桌面應(yīng)用程序來訪問我的網(wǎng)站?3. thinkPHP5中獲取數(shù)據(jù)庫數(shù)據(jù)后默認選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙4. python小白 關(guān)于類里面的方法獲取變量失敗的問題5. python - 如何對列表中的列表進行頻率統(tǒng)計?6. linux運維 - python遠程控制windows如何實現(xiàn)7. Python2中code.co_kwonlyargcount的等效寫法8. django - Python error: [Errno 99] Cannot assign requested address9. python小白,關(guān)于函數(shù)問題10. 求救一下,用新版的phpstudy,數(shù)據(jù)庫過段時間會消失是什么情況?
