1. 程式人生 > 其它 >Uncaught TypeError: Cannot read property ‘error‘ of undefine

Uncaught TypeError: Cannot read property ‘error‘ of undefine

技術標籤:jqueryvue

錯誤資訊
在這裡插入圖片描述這是因為ajax裡無法使用element ui 元件的,會找不到
element ui 是基於vue的

錯誤寫法

 this.$message.error('賬號或密碼不能為空!');

改正

 vm.$message.error('賬號或密碼不能為空!');

給vue例項賦一個名字,使用名字取$message就可以了