Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vue] 如何在全局使用axios的实例呢? #1885

Open
haizhilin2013 opened this issue Feb 10, 2020 · 4 comments
Open

[vue] 如何在全局使用axios的实例呢? #1885

haizhilin2013 opened this issue Feb 10, 2020 · 4 comments
Labels
vue vue

Comments

@haizhilin2013
Copy link
Collaborator

如何在全局使用axios的实例呢?

我也要出题

@haizhilin2013 haizhilin2013 added the vue vue label Feb 10, 2020
@SanChauncy
Copy link

在main.js中导入axios,将axios挂载到Vue的原型对象上。

@lt846786463
Copy link

Vue.prototype.$http=axios

@crush2020
Copy link

在main.js文件下导入axiso,并挂载到vue实例上
import axios from 'axios';
Vue.prototype.$axios = axios;

@hyj443
Copy link

hyj443 commented Oct 28, 2021

axios,不是vue插件,没有install方法,所以不能用Vue.use注册

但你想全局使用,就在入口文件中引入,然后挂在Vue的原型链上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue vue
Projects
None yet
Development

No branches or pull requests

5 participants