为了账号安全,请及时绑定邮箱和手机立即绑定

vue中自定义事件如何传递参数?

vue中自定义事件如何传递参数?

皈依舞 2018-11-14 18:18:28
如代码所示,在子组件中定义和触发了select方法并将type参数传入,在父组件中引入子组件,并监听select事件结果报错:“Property or method "type" is not defined on the instance but referenced during render.” 是我传递参数的方法不对吗?//子组件<button type="button" name="button" class="all" v-bind:class="{'active':selectType===2}" 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 回答

?
墨色风雨

TA贡献1853条经验 获得超6个赞

v-on:select="updSelect"


查看完整回答
反对 回复 2018-12-27
  • 1 回答
  • 0 关注
  • 1900 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号