项目搭建篇:前端界面(vue)

本文介绍了如何新建一个Vue项目,并详细讲述了引入axios库的步骤,包括在main.js中的引用配置和在config的index.js里的设置。通过在app.vue中进行测试,验证了数据获取的功能。项目初步结构分为头部、中部和尾部三个部分。
摘要由CSDN通过智能技术生成

新建vue项目:
http://www.jianshu.com/p/de410cefd788

引入axios

npm install axios -save
2789632-359b6e6126a58bdf.png

添加引用,main.js:

import axios from 'axios'

Vue.prototype.$http = axios
2789632-9866dd48452f4a13.png

配置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>
2789632-72906c63ca9f7aac.png

先搭建三块:
头,中间,尾部

2789632-44e84ea1d8bda4af.png

2789632-de944bf672e64edd.png
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值