javascript - vue中自定义事件如何传递参数?
问题描述
如代码所示,在子组件中定义和触发了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'
相关文章:
1. java - mybatis源码分析2. 修改mysql配置文件的默认字符集重启后依然不生效3. Android-studio导入.so库问题?4. docker容器呢SSH为什么连不通呢?5. 在windows下安装docker Toolbox 启动Docker Quickstart Terminal 失败!6. docker内创建jenkins访问另一个容器下的服务器问题7. css - html根字体设置成很大的值后, 包裹了行内元素的div莫名变高是什么原因8. 请教一个python字符串处理的问题?9. docker api 开发的端口怎么获取?10. docker网络端口映射,没有方便点的操作方法么?

网公网安备