久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

javascript - vue中自定義事件如何傳遞參數(shù)?

瀏覽:198日期:2023-04-30 09:53:45

問題描述

如代碼所示,在子組件中定義和觸發(fā)了select方法并將type參數(shù)傳入,在父組件中引入子組件,并監(jiān)聽select事件

結(jié)果報(bào)錯(cuò):“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'

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 滦南县| 峨眉山市| 淮滨县| 涿州市| 蕲春县| 河东区| 鹿泉市| 台南县| 乐亭县| 英山县| 合川市| 阿尔山市| 潮州市| 肥乡县| 定南县| 榆树市| 商水县| 珠海市| 遵义市| 定边县| 宕昌县| 牡丹江市| 德安县| 陆川县| 新安县| 东源县| 保康县| 延川县| 韩城市| 攀枝花市| 滨州市| 临沂市| 锡林浩特市| 黄平县| 小金县| 上蔡县| 大同市| 九寨沟县| 东乡县| 大名县| 景德镇市|