慕前端2462068
2019-04-18 22:06
new Vue( { el: '#root', data: { firstName: '', lastName: '', fullName: this.firstName + this.lastName // 为什么不能直接让fullName等于firstName和lastName相加 } } )
firstName和lastName是属性并不是变量,直接相加肯定会报错的
因为this的指向的是第2行到第九行的作用域,this只有el和data两个属性
vue2.5入门
146176 学习 · 655 问题
相似问题