问答详情
源自:4-2 使用vue-cli开发TodoList

Cannot read property 'push' of undefined

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

export default {

    data() {

        return {

            inputValue: '',

            last: []

        }

    },

    methods: {

        handleSubmit () {

            this.list.push(this.inputValue)

            this.inputValue = ''

        }

    }

};


提问者:起风了cci 2018-07-12 14:22

个回答

  • 丶沉逑
    2018-07-19 12:26:15

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

  • ry_君莫笑
    2018-07-12 14:49:01

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