Vue - 项目配置 ( element , 安装路由 , 创建路由 )

1,安装element     :      vue add element

2,安装路由          :     vue add router

3,创建路由的过程  :   (1) 新建 vue页面 main.vue , (2)在router.js 文件中引入和注册  , (3)前台引入   <router-link to="/main">Main</router-link>

4, 安装 axios ( 处理接口请求 )  : cnpm i axios          

      (1)http.js 中创建

import axios from 'axios'

const http = axios.create({
    baseURL : 'http://localhost:3000/admin/api'
})

export default http
 
(2)main.js 中引用
 
import http from './http'
Vue.prototype.$http = http
 
(3)然后可以在任意页面中使用 this.$http 访问
 
 
5,服务端  sever 需要安装的模块。    cnpm i express@next mongoose cors
 
 
 

猜你喜欢

转载自www.cnblogs.com/500m/p/11577981.html
今日推荐