vue2.0使用ES6語法的箭頭函數對this做用域的理解

在作vue項目時用到了axios,可是發現axios請求以後的回調函數裏this並不指向當前vue實例,致使瀏覽器報錯。vue 部分代碼: test:function(){ let _self = this;//在外層函數內定義變量存儲當前vue實例。 this.$axios.post("url",{ }).then(function(res){ console.log(this);//結果是:u
相關文章
相關標籤/搜索