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

Cannot read property 'push' of undefined

和老师一样的代码,运行时候总报这个错误,应该怎么解决?

export default {

    data() {

        return {

            inputValue: '',

            last: []

        }

    },

    methods: {

        handleSubmit () {

            this.list.push(this.inputValue)

            this.inputValue = ''

        }

    }

};


正在回答

2 回答

你的data 里是 last ; 你的 methods 是 list 。改成相同就可以了,拼音书写错误

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

this指向问题,没有list属性,改成this.last.push应该就可以了

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

举报

0/150
提交
取消

Cannot read property 'push' of undefined

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号