Vue2+element-ui后台管理系统(静态页面)

这篇具有很好参考价值的文章主要介绍了Vue2+element-ui后台管理系统(静态页面)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

项目所需

node:https://nodejs.org/en/

git:https://git-scm.com/

vue:https://v2.cn.vuejs.org/v2/guide/installation.html

element-ui:https://element.eleme.cn/#/zh-CN/component/installation

项目所需:https://pan.baidu.com/s/1ua0jp9YCtPH6slE49HDUBw

提取码:kkkk

新建项目

在node和vue都调试、配置好的情况下使用vscode 在终端中输入命令

npm i -g @vue/cli 安装vue脚手架

安装成功后通过vue --version 可以查看版本

vue create 项目名 新建项目

vue create control
Vue2+element-ui后台管理系统(静态页面)

空格为取消选项 回车为选中

Vue2+element-ui后台管理系统(静态页面)
Vue2+element-ui后台管理系统(静态页面)
Vue2+element-ui后台管理系统(静态页面)

根据个人习惯选择css样式 本人喜欢使用sass

Vue2+element-ui后台管理系统(静态页面)
Vue2+element-ui后台管理系统(静态页面)

一路回车等待创建

Vue2+element-ui后台管理系统(静态页面)

此界面为创建成功

Vue2+element-ui后台管理系统(静态页面)

cd control 来到项目的目录 进行启动 (git命令自行学习)

Vue2+element-ui后台管理系统(静态页面)

此界面为开启成功

Vue2+element-ui后台管理系统(静态页面)

项目初始化

将以下标记全部删除

Vue2+element-ui后台管理系统(静态页面)

router/index.js最终页面

Vue2+element-ui后台管理系统(静态页面)

将views中文件全部删除,并新建Login.vue 和 Register.vue 文件,修改App.vue

Vue2+element-ui后台管理系统(静态页面)

Login 、 Register 和 App.vue 文件代码

// Login、Register和App.vue 文件代码
<template>
  <div>
    Login // Register 
  </div>
</template>
<script>
  export default {}
</script>
<style lang="scss" scoped>

</style>

在router/index.js中配置路由信息

Vue2+element-ui后台管理系统(静态页面)

在App.vue中添加路由出口 <router-view></router-view>

Vue2+element-ui后台管理系统(静态页面)

此时打开在浏览器打开项目 为此界面即为成功

Vue2+element-ui后台管理系统(静态页面)

页面部署

引入element-ui

Vue2+element-ui后台管理系统(静态页面)

element-ui 哪里需要引哪里

代码

router/index.js

//router/index.js
import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const router = new VueRouter({
  mode: "history", 
  base: process.env.BASE_URL,
  routes:[
    {path:'/login',component:()=>import('../views/Login.vue')},
    {
      path:'/home',
      component:()=>import('../views/Home.vue'),
      children:[
        {path:'/home/one-one',component:()=>import('../views/OneOne.vue')},
        {path:'/home/one-two',component:()=>import('../views/OneTwo.vue')},
        {path:'/home/one-thr',component:()=>import('../views/OneThr.vue')},
        {path:'/home/',redirect:'/home/one-one'}
      ]
    },
    {path:'/register',component:()=>import('../views/Register.vue')},
    {path:'/',redirect:'/login'}
  ]
});

export default router;

main.js

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';

Vue.config.productionTip = false
Vue.use(ElementUI);

new Vue({
  router,
  store,
  el: '#app',
  render: h => h(App)
}).$mount('#app')

Home.vue

<template>
  <div class="control">

    <div class="tit">
      <div class="userName">
        <h4>{{ $store.state.username }}</h4>
        <span>欢迎您</span>
      </div>
      <div class="userInfo">
        <div class="userImg" @click="changeImg" @mouseover="close">
          <img src="" alt="">
        </div>
      </div>

    </div>

    <div class="banner">
      <div class="left">
        <div class="menu">
          <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
            <el-radio-button :label="false">展开</el-radio-button>
            <el-radio-button :label="true">收起</el-radio-button>
          </el-radio-group>
          <el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
            :collapse="isCollapse">
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span slot="title">导航一</span>
              </template>
              <el-menu-item-group>
                <span slot="title">分组一</span>
                <el-menu-item index="1-1" @click="option(11)">选项1</el-menu-item>
                <el-menu-item index="1-2" @click="option(12)">选项2</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group title="分组2">
                <el-menu-item index="1-3" @click="option(13)">选项3</el-menu-item>
              </el-menu-item-group>
              <el-submenu index="1-4">
                <span slot="title">选项4</span>
                <el-menu-item index="1-4-1">选项1</el-menu-item>
              </el-submenu>
            </el-submenu>
            <el-menu-item index="2">
              <i class="el-icon-menu"></i>
              <span slot="title">导航二</span>
            </el-menu-item>
            <el-menu-item index="3" disabled>
              <i class="el-icon-document"></i>
              <span slot="title">导航三</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">导航四</span>
            </el-menu-item>
          </el-menu>
        </div>
      </div>
      <div class="right">
        <router-view></router-view>
      </div>
    </div>

    <div class="ImgMenu" v-if="show" @mouseover="changeImg('self')" @mouseout="close">
      <el-upload class="avatar-uploader" action="https://jsonplaceholder.typicode.com/posts/" :show-file-list="false"
        :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
        <img v-if="imageUrl" :src="imageUrl" class="avatar">
        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
      </el-upload>
      <div class="switch">
        <ul class="conList">
          <li @click="changeUser">
            切换账号
          </li>
        </ul>
      </div>
    </div>

  </div>
</template>

<script>


export default {
  data() {
    return {
      isCollapse: true,
      show: false,
      imageUrl: '',
      t: null
    };
  },
  methods: {
    changeImg(key) {
      if (key == 'self') {
        this.show = true
        clearTimeout(this.t)
      } else {
        this.show = this.show ? false : true
      }

    },
    close() {
      let that = this
      this.t = setTimeout(() => {
        that.show = false
      }, 3000);
    },
    changeUser() {
      this.$router.push('/login')
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    },

    // 切换选项
    option(key) {
      switch (key) {
        case 11:
          this.$router.push('/home/one-one')
          break;
        case 12:
          this.$router.push('/home/one-two')
          break;
        case 13:
          this.$router.push('/home/one-thr')
          break;
      }
    }

  },
  mounted() {
    this.$store.state.username = localStorage.getItem('username')
  },
  beforeRouteLeave(to, from, next) {
    localStorage.clear()
    next()
  }
}
</script>

<style lang="scss" scoped>
ul {
  list-style: none;
}

.control {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.conList {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.tit {
  width: 100%;
  height: 50px;
  background-color: rgb(27, 101, 237);
  display: flex;
  justify-content: right;

  .userInfo {
    width: 50px;
    height: 50px;
    margin-right: 30px;

    .userImg {
      width: 100%;
      height: 100%;
      border-radius: 50%;
      background-color: rgb(11, 144, 100);
    }
  }
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}

.ImgMenu {
  width: 200px;
  height: 400px;
  border-radius: 10px;
  position: absolute;
  right: 30px;
  top: 70px;
  background-color: rgba(155, 150, 150, .3);
}

.userName {
  width: 200px;
  height: 50px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.banner {
  width: 100%;
  display: flex;
  justify-content: space-between;
  flex: 1;
}

.left {
  width: 15%;
  height: 100%;
}

.right {
  width: 85%;
  height: 100%;
}
</style>

Login.vue

<template>
  <div class="login">
    <el-form :model="admin" ref="login" :rules="rules" @keyup.enter.native="login">
      <el-form-item prop="username">
        <el-input placeholder="请输入用户名" v-model="admin.username"></el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input placeholder="请输入密码" type="password" v-model="admin.password"></el-input>
      </el-form-item>
      <el-button @click="login">
        登录
      </el-button>
      <el-button>
        <router-link to="/register">注册</router-link>
      </el-button>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      admin: {
        username: "",
        password: ""
      },
      rules: {
        username: [
          { required: true, message: "用户名格式错误", trigger: "blur" },
          { min: 3, max: 15, message: "长度在 3 到 15 个字符", trigger: "blur" }
        ],
        password: [
          { required: true, message: "密码格式错误", trigger: "blur" },
          { min: 3, max: 15, message: "长度在 3 到 15 个字符", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    login() {
      let that = this
      this.$refs.login.validate((valid) => {
        if (valid) {
          that.$router.push('/home')
        }
        else {
          console.log("error submit!!");
          return false;
        }
      });
    }
  },
  beforeRouteLeave(to, from, next) {
    this.$store.state.username = this.admin.username
    localStorage.setItem('username', this.admin.username)
    next()
  }
}
</script>

<style lang="scss" scoped>
.login {
  width: 620px;
  height: 349px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 20px 30px;
  border-radius: 20px;
  box-shadow: 5px 5px 20px rgb(39, 38, 38);
  background-image: linear-gradient(skyblue,orange);
}
</style>

OneOne.vue

<template>
  <div class="one-two">
    <h2>1-1</h2>
    <ul class="dataList">
      <li v-for="item in oneData">
       {{ item }}
      </li>
    </ul>
  </div>
</template>

<script>
  export default {
    data(){
      return{
        oneData:['111','222','333','444']
      }
    }
    
  }
</script>

<style lang="scss" scoped>
*{
  margin: 0;
  padding: 0;
}
ul{
  list-style: none;
}
.one-two{
  width: 100%;
  height: 100%;
}
.dataList{
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
}
.dataList li{
  width: 533px;
  height: 300px;
  img{
    width: 100%;
  }
}
</style>

自己动手丰衣足食!!!文章来源地址https://www.toymoban.com/news/detail-464239.html

到了这里,关于Vue2+element-ui后台管理系统(静态页面)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 黑马程序员课程Vue实战项目_Element-ui——电商后台管理系统-商品管理(商品列表)

    黑马程序员课程Vue实战项目_Element-ui——电商后台管理系统-商品管理(商品列表)

    目录 商品列表 一.创建一个子分支 二.创建组件 三.绘制商品列表的页面基本结构 1.面包屑导航  2.卡片视图区域 四.功能 1.搜索  2.删除  3.添加 五.提交代码 git branch——查看当前所在分支 git checkout -b goods_list——创建新的子分支goods_list git branch——查看当前所在分支 git pus

    2024年02月08日
    浏览(10)
  • 基于vue-cli创建后台管理系统前端页面——element-ui,axios,跨域配置,布局初步,导航栏

    基于vue-cli创建后台管理系统前端页面——element-ui,axios,跨域配置,布局初步,导航栏

    1.vue-cli创建前端工程,安装element-ui,axios和配置; 2.前端跨域的配置,请求添加Jwt的设置; 3.进行初始化布局,引入新增页面的方式; 4.home页面导航栏的设置,一级目录,二级目录; 安装成功 布局初步 1.vue-cli创建前端工程,安装element-ui,axios和配置; 2.前端跨域的配置,请

    2024年02月09日
    浏览(13)
  • 管理系统的前端模板(vue2+Element UI)

    管理系统的前端模板(vue2+Element UI)

    目录 前言 一、模板展示图 二、获取的方式及操作运行步骤  (一)获取方式 (二)操作步骤  1.下载安装node.js  2.下载完成解压缩后在idea的里面打开终端。 3.输入下载相关依赖的命令 4.运行项目的命令 5.然后把给到的地址浏览器打开就可以了  三、代码的展示(这个点的内

    2024年02月05日
    浏览(15)
  • Spring Boot + Vue + Element UI的网上商城后台管理之订单管理系统

    以下是订单管理系统的思维导图,展示了系统的主要功能和模块之间的关系。 根节点 订单列表 查看订单列表 搜索订单 排序订单 导出订单列表 订单详情 查看订单详情 修改订单信息 修改商品信息 修改价格 修改收货地址 取消订单 处理订单 处理订单操作 确认订单 拒绝订单

    2024年02月03日
    浏览(22)
  • Vue+Element-ui+SpringBoot搭建后端汽车租赁管理系统

    Vue+Element-ui+SpringBoot搭建后端汽车租赁管理系统

    最近在做项目,花了一周的时间搭建了一个十分完备的汽车租赁后端管理系统。页面采用 纯Vue2+Element-ui搭建 ,后端采用 Springboot+Mybatis 搭建,数据库采用 Mysql 。包括了登录验证,根据不同权限进入不同界面、数据增删改查、表格分页、表格excel导出等等功能。已开源至git,在

    2024年02月09日
    浏览(13)
  • 从0开始写Vue项目-Vue2集成Element-ui和后台主体框架搭建

    从0开始写Vue项目-Vue2集成Element-ui和后台主体框架搭建

    1. 从0开始写Vue项目-环境和项目搭建_慕言要努力的博客-CSDN博客 一、了解Element-ui  1.Element-UI Element,一套为开发者、设计师和产品经理准备的基于 Vue 2.0 的桌面端组件库 Element UI是基于Vue 2.0的 Element UI 提供一组组件 Element UI 提供组件的参考实例, 直接复制 2.官网  地址:https:

    2024年02月12日
    浏览(10)
  • 【前端】Vue+Element UI案例:通用后台管理系统-面包屑、tag栏

    【前端】Vue+Element UI案例:通用后台管理系统-面包屑、tag栏

    参考视频: VUE项目,VUE项目实战,vue后台管理系统,前端面试,前端面试项目 案例 链接 【前端】Vue+Element UI案例:通用后台管理系统-导航栏(视频p1-16) https://blog.csdn.net/karshey/article/details/127640658 【前端】Vue+Element UI案例:通用后台管理系统-Header+导航栏折叠(p17-19) http

    2024年02月09日
    浏览(22)
  • VUE2+Element-ui树形控件tree结构的值获取和传给后台

    VUE2+Element-ui树形控件tree结构的值获取和传给后台

    最近做到了权限管理模块 其中的菜单权限需要用到tree结构进行多选功能的渲染操作 废话少说,直接上代码 将tree结构放在form中配合表单使用 并附带全选和全不选,展开和折叠功能 其中的show-checkbox作用是对tree数据的多选模式 要写在data中的数据 其中defaultProps一定不能忘记

    2024年02月05日
    浏览(39)
  • TinyVue - 华为云 OpenTiny 出品的企业级前端 UI 组件库,免费开源,同时支持 Vue2 / Vue3,自带 TinyPro 中后台管理系统

    TinyVue - 华为云 OpenTiny 出品的企业级前端 UI 组件库,免费开源,同时支持 Vue2 / Vue3,自带 TinyPro 中后台管理系统

    华为最新发布的前端 UI 组件库,支持 PC 和移动端,自带了 admin 后台系统,完成度很高,web 项目开发又多一个选择。 关于 OpenTiny 和 TinyVue 在上个月结束的华为开发者大会2023上,官方正式进行发布了 OpenTiny,这是华为云出品的企业级设计体系统,一套前端 UI 组件库。适配

    2024年02月11日
    浏览(14)
  • vue3 + vite + ts + element-ui搭建后台管理框架

    vue3 + vite + ts + element-ui搭建后台管理框架

    vue3官网 vue3官网 vite vite官网连接 npm 安装 按照提示输出即可! vite 中使用 less 或 scss 安装后在style 中设置对应的 scss 或 less,推荐scss编译 安装less依赖 安装sass依赖 推荐使用插件,vite.config.js配置; unplugin-vue-components // 自动导入vue中hook reactive ref等AIP; unplugin-auto-import // 自动

    2024年02月15日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包