鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ vue中,如果使用了axios攔截,是不是就不可以使用mock.js模擬數(shù)據(jù)了?

vue中,如果使用了axios攔截,是不是就不可以使用mock.js模擬數(shù)據(jù)了?(返回為undefined)

我引入了mock.js文件(內(nèi)容是我返回的數(shù)據(jù)),然后在頁(yè)面中調(diào)接口,走了mock.js 但是返回為undefined.
clipboard.png

clipboard.png

回答
編輯回答
青瓷

原因很簡(jiǎn)單,你要在你的攔截器里面把數(shù)據(jù) return 出來

axios.interceptors.response.use(function resolve(res) {
    console.log('response')
    return res
  });

如果還不清楚:你可以看看我的 https://segmentfault.com/a/11...

2017年10月28日 04:12