javascript - vue中自定義事件如何傳遞參數(shù)?
問題描述
如代碼所示,在子組件中定義和觸發(fā)了select方法并將type參數(shù)傳入,在父組件中引入子組件,并監(jiān)聽select事件
結果報錯:“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'
相關文章:
1. docker容器呢SSH為什么連不通呢?2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. nignx - docker內nginx 80端口被占用4. debian - docker依賴的aufs-tools源碼哪里可以找到啊?5. 前端 - ng-view不能加載進模板6. android clickablespan獲取選中內容7. docker網(wǎng)絡端口映射,沒有方便點的操作方法么?8. python - from ..xxxx import xxxx到底是什么意思呢?9. javascript - iframe 為什么加載網(wǎng)頁的時候滾動條這樣顯示?10. 請教各位大佬,瀏覽器點 提交實例為什么沒有反應
