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. java - 如何用圖畫的方式有效地表示多線程?2. bootstrp是col-md-12列的,只有col-md-10有內(nèi)容,可以讓沒有內(nèi)容的不占據(jù)位置嗎;3. 在windows下安裝docker Toolbox 啟動Docker Quickstart Terminal 失敗!4. python - Fiddler+Android模擬器抓取app,json數(shù)據(jù)被加密了,如何解析?5. html5 - 剛接觸H5,為什么我覺得很多標簽都沒什么用呢?6. windows C++ 一般使用什么技術(shù)調(diào)用Webservice接口7. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.8. javascript - 小程序中遇到j(luò)s執(zhí)行時序問題9. java-ee - JAVA8 lambdas表達式 改變外面變量的值10. html - eclipse 標簽錯誤
