本文共 741 字,大约阅读时间需要 2 分钟。
import axios from 'axios'Vue.prototype.$axios = axios;axios.defaults.baseURL = '/api';
注: target中的地址可变
module.exports = { dev: { // Paths assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: { '/api': { // 此处的写法,目的是为了 将 /api 替换成 https://api.qq.jsososo.com target: 'https://api.qq.jsososo.com', // 允许跨域 changeOrigin: true, ws: true, pathRewrite: { '^/api': '' } } } }}
methods: { async fetchSwiperList() { const res = await this.$axios.get("/recommend/banner"); console.log(res) }},
转载地址:http://ztlqf.baihongyu.com/