安装axios
npm install axios -S
main.js 配置
import axios from 'axios' //基础配置 axios.defaults.baseURL = "https://localhost:44324/"; const app = createApp(App) app.config.globalProperties.$http =axios app.use(naive).use(store).use(router).mount('#app')
页面用法
const { proxy } = getCurrentInstance(); let login = ()=>{ proxy.$http.get('Api/values').then((res) => { console.log(res) }); }