I wrote a function to get user info and import it in other places, how can I use it to get data? Can someone please help me?
export function userInfo () {
let res
this.$http({
url: this.$http.adornUrl('/sys/user/info'),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
res = data
}
})
return res
}
I use userInfo() and got error: Error in activated hook: "TypeError: Cannot read property '$http' of undefined"
import {userInfo} from './getUserInfo'
activated () {
userInfo()
}