新建vue项目:
http://www.jianshu.com/p/de410cefd788
引入axios
npm install axios -save
添加引用,main.js:
import axios from 'axios'
Vue.prototype.$http = axios
配置cofig下的index.js
proxyTable: {
'/api': {
target: 'http://localhost:8032',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
}
},
在app.vue里做个测试,看看能不能获取数据
<template>
<div id="app">
{{Theme}}
<router-view></router-view>
</div>
</template>
<script>
export default {
data () { return {Theme: '', name: 'mynae'} },
mounted: function () {
this.$http.get('/api/Index/GetTheme').then(response => {
console.log(response)
console.log(response.data)
console.log(response.data.Name)
this.Theme = response.data.Name
})
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
先搭建三块:
头,中间,尾部