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. mac連接阿里云docker集群,已經(jīng)卡了2天了,求問?2. angular.js - angular內(nèi)容過長展開收起效果3. docker網(wǎng)絡端口映射,沒有方便點的操作方法么?4. debian - docker依賴的aufs-tools源碼哪里可以找到啊?5. vim - docker中新的ubuntu12.04鏡像,運行vi提示,找不到命名.6. 為什么我ping不通我的docker容器呢???7. 百度地圖api - Android 百度地圖 集成了定位,導航 相互的jar包有沖突?8. html5和Flash對抗是什么情況?9. golang - 用IDE看docker源碼時的小問題10. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?

網(wǎng)公網(wǎng)安備