Cannot read property 'push' of undefined
和老師一樣的代碼,運行時候總報這個錯誤,應該怎么解決?
export default {
????data() {
????????return {
????????????inputValue: '',
????????????last: []
????????}
????},
????methods: {
????????handleSubmit () {
????????????this.list.push(this.inputValue)
????????????this.inputValue = ''
????????}
????}
};
2018-07-19
你的data 里是 last ; 你的 methods 是 list 。改成相同就可以了,拼音書寫錯誤
2018-07-12
this指向問題,沒有l(wèi)ist屬性,改成this.last.push應該就可以了