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
 
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM