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. chrome - linux系统下如何通过java获取客户端ip和mac地址?2. javascript - sublime已经安装了babel插件和sublimelinter-jshint为什么还是显示es6语法错误?3. 前端 - flex布局采用space-around这种方法,但是最后一行如何让他左对齐?4. css - 手机app中rem的基准值计算错误5. android - Manifest.xml自己生成的GMS服务怎么删掉呢?6. node.js - node的npm无法安装7. java - git项目迁移到SVN怎么实现的?哪位大神指点指点8. 关于thinkphp 5.1中,ajax提交数据url的格式写法,加花括号就出错,请老师指点9. 这节课上传文件报错10. mysqli_close是基本每个文件都要添加吗?

网公网安备