赞
踩
1:安装axios
npm i axios
2:在mian.js里面注册axios
- //引入axios
- import axios from "axios";
- //全局挂载axios
- const app = createApp(App);
- app.config.globalProperties.$http = axios;
- app.use(store).use(router).mount("#app");
3:使用的时候
- //通过getCurrentInstance获取axios
- const { proxy } = getCurrentInstance() as any;
- //使用的时候
- proxy.$http.get()...//以此类推
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。