前端环境搭建

  • 搭建脚手架

    • 创建项目

      vue init webpack book

      # 这里需要进行一些配置,默认回车即可
      This will install Vue 2.x version of the template.
      
      For Vue 1.x use: vue init webpack#1.0 my-project
      
      ? Project name my-project
      ? Project description A Vue.js project
      ? Author runoob <test@runoob.com>
      ? Vue build standalone
      ? Use ESLint to lint your code? Yes
      ? Pick an ESLint preset Standard
      ? Setup unit tests with Karma + Mocha? Yes
      ? Setup e2e tests with Nightwatch? Yes
      
         vue-cli · Generated "my-project".
      
         To get started:
      
           cd my-project
           npm install
           npm run dev
      
         Documentation can be found at https://vuejs-templates.github.io/webpack
      
  • 前端配置

    • 前端跨域

      proxyTable: {
            '/api': {  //使用"/api"来代替"http://f.apiplus.c" 
              target: 'http://127.0.0.1:8000/', //源地址 
              changeOrigin: true, //改变源 
              pathRewrite: { 
                '^/api': '' //路径重写 
                } 
            } 
       },
      
    • 安装axios

      cnpm install axios

    • 注册 axios

      // main.js
      import axios from 'axios'
      Vue.prototype.axios = axios
      

results matching ""

    No results matching ""