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. javascript - 修改表单多选项时和后台同事配合的问题。2. mysql - 索引过滤性不好是由什么原因引起的,应该怎么解决3. javascript - vue生成一维码?求助!!!!!急4. javascript - H5页面怎么查看console信息?5. android - Listview模仿朋友圈点赞的TextView没有刷新?6. dockerfile - [docker build image失败- npm install]7. mysql - 我的myeclipse一直连显示数据库连接失败,不知道为什么8. docker内创建jenkins访问另一个容器下的服务器问题9. 网页爬虫 - Python:爬虫的中文编码问题?10. angular.js - angularjs 怎么封装 upload 上传
