vue中main.js文件配置,使用axios像后端发送数据
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
Vue.config.productionTip = false
// 全局使用
Vue.prototype.axios = axios
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})
vue中index.js文件里proxyTable将这块内容粘贴上修改8000端口号就可以
proxyTable: {
'/api': { //使用"/api"来代替"http://f.apiplus.c"
target: 'http://localhost:8000', //源地址 对应后端Django 8000端口号
changeOrigin: true, //改变源
pathRewrite: {
'^/api': '' //路径重写
}
}
},