文章目录
一、文件修改config/index.jsmain.jsApp.vue
二、执行命令
一、文件修改
config/index.js
'use strict'
const path
= require('path')
module
.exports
= {
dev
: {
assetsSubDirectory
: 'static',
assetsPublicPath
: '/',
proxyTable
: {
'/api': {
target
: 'http://localhost:8888/',
changeOrigin
: true,
pathRewrite
: {
'^/api': ''
}
}
},
......
main.js
import Vue
from 'vue'
import App
from './App'
import router
from './router'
import Axios
from 'axios'
Vue
.config
.productionTip
= false
Vue
.prototype
.$axios
= Axios
Vue
.prototype
.IP_PORT = '/api'
new Vue({
el
: '#app',
router
,
components
: { App
},
template
: '<App/>'
})
App.vue
<template
>
<div id
="app">
<img src
="./assets/logo.png">
<router
-view
/>
</div
>
</template
>
<script
>
export default {
name
: 'App',
mounted () {
this.$axios
.post(this.IP_PORT + '/book/name', {param
: 'Java'}).then(data
=> {
console
.log('data', data
)
})
}
}
</script
>
二、执行命令
npm install
npm install axios
npm run dev
转载请注明原文地址:https://ipadbbs.8miu.com/read-44266.html