国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

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

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

問題描述

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

結果報錯:“Property or method 'type' is not defined on the instance but referenced during render.” 是我傳遞參數的方法不對嗎?

//子組件<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'

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 武夷山市| 怀来县| 剑川县| 会宁县| 于田县| 新巴尔虎左旗| 怀柔区| 建阳市| 思茅市| 吴堡县| 安达市| 山阴县| 舞阳县| 沅陵县| 织金县| 台湾省| 天门市| 内乡县| 酉阳| 昌图县| 旬邑县| 交城县| 两当县| 勐海县| 治县。| 浦城县| 贵德县| 尉氏县| 柞水县| 出国| 岱山县| 安新县| 河南省| 卓资县| 巢湖市| 太白县| 呼伦贝尔市| 准格尔旗| 许昌县| 绍兴县| 资中县|