封装axios并全局引入


自定义工具类utils  创建js文件

import axios from "axios";

const request = axios.create({
    baseURL: 'http://localhost:3000',
})

export default request

main.js全局引入

// 导入自定义包
import request from '@/utils/request.js';
//其中$xx为新命的名
Vue.prototype.$axios = request;

使用时直接this.$axios({})

详情封装见

TRANSLATE with x English
Arabic Hebrew Polish
Bulgarian Hindi Portuguese
Catalan Hmong Daw Romanian
Chinese Simplified Hungarian Russian
Chinese Traditional Indonesian Slovak
Czech Italian Slovenian
Danish Japanese Spanish
Dutch Klingon Swedish
English Korean Thai
Estonian Latvian Turkish
Finnish Lithuanian Ukrainian
French Malay Urdu
German Maltese Vietnamese
Greek Norwegian Welsh
Haitian Creole Persian  
Bing Webmaster Portal Back