我使用“ this.toast.error”显示消息。无法访问显示消息的“ this”有问题吗?
HttpService.js:
const http = axios.create(defaultOptions)
http.interceptors.response.use(
response => {
const myResponse = { ...response.data }
if (
(myResponse.status === 'success' &&
(myResponse.object === null ||
(myResponse.object && !myResponse.object.error))) ||
(myResponse.meta && myResponse.meta.code === 200)
) {
return myResponse.object || myResponse
}
return handleError(response)
},
error => {
return this.$toast.error(response, {
timeout: 2500,
y: 'top',
color: 'var(--v-error-base)'
})
}
)
export { http }