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. mysql优化 - mysql count(id)查询速度如何优化?2. python - django 里自定义的 login 方法,如何使用 login_required()3. javascript - git clone 下来的项目 想在本地运行 npm run install 报错4. node.js - node_moduls太多了5. mysql主从 - 请教下mysql 主动-被动模式的双主配置 和 主从配置在应用上有什么区别?6. angular.js - 不适用其他构建工具,怎么搭建angular1项目7. 主从备份 - 跪求mysql 高可用主从方案8. android-studio - Android 动态壁纸LayoutParams问题9. python如何不改动文件的情况下修改文件的 修改日期10. 在Java中System.out.println 只能在method中使用吗?
