采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
let _this = this // 匿名函数 _this.$refs.player.addEventListener('canplay', function () { _this.duration = this.duration }, false) // 箭头函数 _this.$refs.player.addEventListener('canplay', () => { _this.duration = this.duration }, false)
请教一下老师为什么
匿名函数会有问题吧,匿名函数中的 this.duration 的 this 不会指向组件实例
登录后可查看更多问答,登录/注册
Vue.js高级知识应用大集合,实战企业级APP,教你搞定组件化开发。
1.9k 32
2.5k 31
2.0k 26
1.9k 25
2.3k 24
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号