为了账号安全,请及时绑定邮箱和手机立即绑定

为什么fullName不能直接在data中写成firstName + lastName

new Vue(
    {
        el: '#root',
        data: {
            firstName: '',
            lastName: '',
            fullName: this.firstName + this.lastName // 为什么不能直接让fullName等于firstName和lastName相加
        }
    }
)


正在回答

5 回答

firstName和lastName是属性并不是变量,直接相加肯定会报错的

0 回复 有任何疑惑可以回复我~

因为this的指向的是第2行到第九行的作用域,this只有el和data两个属性

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

为什么fullName不能直接在data中写成firstName + lastName

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信