项目地址

https://github.com/PanJiaChen/vue-admin-template

这是一个 极简的 vue admin 管理后台 它只包含了 Element UI & axios & iconfont & permission control & lint,这些搭建后台必要的东西。

  • 在win环境下安装
  • nodejs版本8.11.3
# Clone project
#生成vue-admin-template目录
git clone https://github.com/PanJiaChen/vue-admin-template.git # Install dependencies
#先进入vue-admin-template目录
#命令会生成node_modules目录,所有依赖都在其中
#如果安装失败,删除node_modules目录,重新安装依赖
npm install # Serve with hot reload at localhost:9528
npm run dev # Build for production with minification
npm run build # Build for production and view the bundle analyzer report
npm run build --report

  

config/dev.env.js

'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env') module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
BASE_API: '"http://127.0.0.1:8008/"',
})
#在config里有dev环境配置和prod环境配置
#将dev的BASE_API设定为后台的API地址,这样vue就能访问后端API数据了
#由于是跨域访问,所以在后台需要添加跨域访问的功能

  

src/api/mofang.js

import request from '@/utils/request'

export function getMofangMailList() {
return request({
url: 'GameGroup/',
method: 'get'
})
}
#在src/api目录下建立mofang.js文件
#创建getMofangMailList方法
#url和config里的BASE_API拼接后就是API的请求地址
#使用get方法获取数据

  

router/index.js

  {
path: '/mofang',
component: Layout,
children: [{
path: '',
name: 'Gamegroup',
component: () => import('@/views/mofang/index'),
meta: { title: 'Gamegroup', icon: 'example' }
}]
},
#添加一条路由信息

  

src/views/mofang/index.vue

<template>
<div class="dashboard-container">
<el-table
:data="tableData"
border
style="width: 100%">
<el-table-column
prop="id"
label="编号"/>
<el-table-column
prop="name"
label="名称"/>
<el-table-column
prop="mail"
label="邮箱"/>
</el-table>
</div>
</template> <script>
import { getMofangMailList } from '@/api/mofang'
export default {
data() {
return {
tableData: []
}
},
created() {
this.fetchData()
},
methods: {
fetchData() {
getMofangMailList().then(response => {
this.tableData = response
})
}
}
}
</script> <style rel="stylesheet/scss" lang="scss" scoped>
.dashboard {
&-container {
margin: 30px;
}
&-text {
font-size: 30px;
line-height: 46px;
}
}
</style>
#created()方法在dom的生命周期内执行,调用this.fetchData()
#fetchData()中,执行getMofangMailList方法
#在api中,使用get方法向api地址请求数据并return
#使用then方法,return的数据传参给response
#把response 的数据赋值给this.tableData
#this.tableData渲染到dom表单

  

vue教程4-vueadmin上手的更多相关文章

  1. vue教程3-05 vue组件数据传递、父子组件数据获取,slot,router路由

    vue教程3-05 vue组件数据传递 一.vue默认情况下,子组件也没法访问父组件数据 <!DOCTYPE html> <html lang="en"> ...

  2. vue教程3-04 vue.js vue-devtools 调试工具的下载安装和使用

    vue教程3-04 vue.js vue-devtools vue调试工具的安装和使用 一.vue-devtools 下载与安装 1.需要 fan qiang 2.打开谷歌浏览器设置--->扩展 ...

  3. vue教程3-03 vue组件,定义全局、局部组件,配合模板,动态组件

    vue教程3-03 vue组件,定义全局.局部组件,配合模板,动态组件 一.定义一个组件 定义一个组件: 1. 全局组件 var Aaa=Vue.extend({ template:'<h3&g ...

  4. vue教程3-02 vue动画

    vue教程3-02 vue动画 以下代码,已经用包管理器下载好vue,animate <!DOCTYPE html> <html lang="en"> &l ...

  5. vue教程3-01 路由、组件、bower包管理器使用

    vue教程3-01 路由.组件.包管理器 以下操作前提是 已经安装好node.js npm bower-> (前端)包管理器 下载: npm install bower -g 验证: bower ...

  6. vue教程2-08 自定义键盘信息、监听数据变化vm.$watch

    vue教程2-08 自定义键盘信息 @keydown.up @keydown.enter @keydown.a/b/c.... 自定义键盘信息: Vue.directive('on').keyCode ...

  7. vue教程2-07 自定义指令

    vue教程2-07 自定义指令 自定义指令: 一.属性: Vue.directive(指令名称,function(参数){ this.el -> 原生DOM元素 }); <div v-re ...

  8. vue教程2-07 微博评论功能

    vue教程2-07 微博评论功能 <!doctype html> <html> <head> <meta charset="utf-8"& ...

  9. vue教程2-06 过滤器

    vue教程2-06 过滤器 过滤器: vue提供过滤器: capitalize uppercase currency.... <div id="box"> {{msg| ...

  10. vue教程2-05 v-for循环 重复数据无法添加问题 加track-by='索引'

    vue教程2-05 v-for循环 重复数据无法添加问题  加track-by='索引' 解决问题的代码示例: <!DOCTYPE html> <html lang="en ...

随机推荐

  1. ASP.NET MVC3中的路由系统

    MVC中,用户访问的地址并不映射到服务器中对应的文件,而是映射到对应Control里对应的ActionMethod,由ActionMethod来决定返回用户什么样的信息.而把用户访问的地址对应到对应的 ...

  2. 学习c语言的第14天

    #include <stdio.h> #include <string.h> struct student { int age; char sex; char name[100 ...

  3. oracle_sql的用法?

    本机连接oracle 数据库?打开cmd ----> 不同的用户有不同的用户名密码 ----> sqlplus scott/tiger(安装oracle数据库预留的用户)---- 回车 - ...

  4. 同程联盟景点门票动态程序 beta1.0源码

    经过一段时间的开发,以及内部测试,同程网联盟景区新版程序正式发布推出,感谢广大联盟会员一直以来的支持与关注! 同程网联盟景区新版程序新功能介绍: 1.统一的页面风格.页面风格将与随后推出的度假线路.酒 ...

  5. openfire插件开发环境

    创建java工程 SamplePlugin: package com.hoo.server.plugin; import java.io.File; import org.jivesoftware.o ...

  6. linux 网络编程 inet_pton & inet_ntop函数

    #include <arpa/inet.h> int inet_pton(int family,const char * strptr,void * addrptr); 返回:--成功, ...

  7. OpenCV——高斯模糊与毛玻璃特效

    // define head function #ifndef PS_ALGORITHM_H_INCLUDED #define PS_ALGORITHM_H_INCLUDED #include < ...

  8. PS 色调— —颜色梯度

    clc; clear all; close all; addpath('E:\PhotoShop Algortihm\Image Processing\PS Algorithm'); I=imread ...

  9. 【bzoj1232】[Usaco2008Nov]安慰奶牛cheer

    问题描述 Farmer John变得非常懒,他不想再继续维护供奶牛之间供通行的道路.道路被用来连接N个牧场,牧场被连续地编号为1到N.每一个牧场都是一个奶牛的家.FJ计划除去P条道路中尽可能多的道路, ...

  10. uC/OS-II源码分析(四)

    内核结构 1,  临界区,OS_ENTER_CRITICAL和OS_EXIT_CRITICAL 为了处理临界区代码,必须关中断,等处理完毕后,再开中断.关中断可以避免其他任务或中断进入临界区代码.uC ...