2 Star 2 Fork 0

xiaonqedu/vuedemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

演示地址: https://taylorchen709.github.io/vue-admin/

1.1 安装项目依赖&启动项目

npm install    # 安装依赖
npm run dev    # 启动项目

1.2 目录结构

  • build : webpack配置文件
  • config : webpack配置文件
  • dist : build编译后文件
  • src : 自己写代码文件件
    • api : 使用axios对请求封装模块
    • assets : 图片等资产文件夹
    • common : 常用公共方法文件夹
    • components : 官方建议存放组件位置
    • mock : 模拟后端返回数据模块(无需关注)
    • router : vue路由文件
    • styles : css样式
    • views : 自己开发的 .vue 页面
    • vuex : vue团队简化组件间的通信定义的规范
    • App.vue : 一般用做网站首页
    • main.js : 入口文件,主要作用是初始化vue实例
  • static : css等静态资源存放位置

1.3 登录页面介绍(发送post请求)

  1. 创建 src/views/Login.vue 文件
  1. src\router\index.js配置路由
{
    path: '/login',
    component: page('Login'),
    name: '',
    hidden: true
},

3.在src\api\api.js 定义发送请求函数

export const requestLogin = params => { return axios.post(`${base}/login`, params).then(res => res.data); };

4.在src/views/Login.vue发送post请求

//1、导入方法
import { requestLogin } from '../api/api';  

//2、直接使用导入的方法即可
var loginParams = { username: this.ruleForm2.account, password: this.ruleForm2.checkPass };
requestLogin(loginParams).then(data => {
  this.logining = false;
  let { msg, code, user } = data;
  if (code !== 200) {
	this.$message({
	  message: msg,
	  type: 'error'
	});
  } else {
	sessionStorage.setItem('user', JSON.stringify(user));
	this.$router.push({ path: '/' });
  }
});

1.4 用户list页(发送get请求)

1.创建 src/views/User.vue 文件

2.src\router\index.js配置路由

{
    path: '/',
    component: Home,
    name: '导航一',
    iconCls: 'el-icon-message',//图标样式class
    children: [
        { path: '/user', component: page('nav1/User'), name: '用户' },
    ]
},

3.在src\api\api.js 定义发送请求函数

export const getUserList = params => { return axios.get(`${base}/user/list`, { params: params }); };

4.在src/views/User.vue发送get请求

//1导入方法
import { getUserList } from '../../api/api';

//2直接使用导入的方法即可
getUser: function () {
    let para = {
        name: this.filters.name
    };
    this.loading = true;
    getUserList(para).then((res) => {
        this.users = res.data.users;
        this.loading = false;
    });
}
MIT License Copyright (c) 2016-present taylorchen709 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

对vue框架简单封装,方便初学者快速上手vue项目 展开 收起
NodeJS
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/xiaonqedu/vuedemo.git
git@gitee.com:xiaonqedu/vuedemo.git
xiaonqedu
vuedemo
vuedemo
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891