首页 > 其他分享 >VUE学习笔记(八)

VUE学习笔记(八)

时间:2024-05-29 10:46:30浏览次数:18  
标签:el VUE center views color 笔记 学习 vue import

登录页设计

src下新建auth文件夹,新建auth.service.js,

auth文件夹下新建views文件夹,view文件夹下新建UserLogin.vue

UserLogin.vue

<template>
    <div class="login">
        <div class="body">
            <div class="container">
                <h2>用户登陆</h2>
                <el-form   :model="ruleForm" ref="loginForm" class="login-form" >
                    <el-form-item label="账号">
                        <el-input v-model="ruleForm.email" />
                    </el-form-item>
                    <el-form-item label="密码">
                        <el-input type="password" v-model="ruleForm.password" />
                    </el-form-item>
                    <el-button style="width: 100%;" type="primary">登陆</el-button>
                </el-form>
            </div>
        </div>
    </div>
</template>
<script setup>
import {  reactive,toRefs } from 'vue';

const state=reactive({
    ruleForm:{
        email:"[email protected]",
        password:"ant123"
    }
})

const {ruleForm}=toRefs(state)
</script>
<style scoped>
.login {
    background: url("../../assets/bg.jpg");
    height: 100%;
    width: 100%;
    position: fixed;
    background-size: cover;
}
.body{
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20%;
}
.container{
    width: 420px;
    height: 250px;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: 10px;
    border-radius: 0px 21px 41px 0px rgba(0,0,0,0.2);
    font-size: 12px;
}
</style>

调整路由,将分类管理的路由合并到分项里

src/router/index.js

import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/HomeView.vue";

const routes = [
  {
    path: "/login",
    name: "login",
    component: () => import("@/auth/views/UserLogin.vue"),
  },
  {
    path: "/",
    name: "/",
    component: () => import("@/views/LayoutView.vue"),
    redirect:'/home',
    children: [
      {
        path: "/",
        name: "home",
        component: HomeView,
      },
      {
        path: "/about",
        name: "about",
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () =>
          import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
      },
      {
        path: "/category",
        name: "category",
        component: () =>
          import(/* webpackChunkName: "about" */ "../views/CategoryView.vue"),
      },
      {
        path: "/addCategory",
        name: "addCategory",
        component: () => import("../components/AddCategory.vue"),
      }
    ]
  }
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;

src下views新建LayoutView.vue,调整旧页面主页

<template>
    <el-container class="layout-container-demo">
      <el-aside width="200px">
        <el-scrollbar>
          <div class="mb-2 logo">Vue+WEBAPI</div>
          <el-menu :default-openeds="['1', '2']" active-text-color="#ffd04b" background-color="#303133" text-color="#fff"
            router="true">
            <el-sub-menu index="1">
              <template #title>
                <el-icon>
                  <message />
                </el-icon>店铺管理
              </template>
              <el-menu-item-group>
  
                <el-menu-item index="/"><el-icon>
                    <HomeFilled />
                  </el-icon>首页</el-menu-item>
  
                <el-menu-item index="/category"><el-icon>
                    <Operation />
                  </el-icon>分页管理</el-menu-item>
                <el-menu-item index="1-3"><el-icon>
                    <ShoppingCart />
                  </el-icon>商品管理</el-menu-item>
              </el-menu-item-group>
  
            </el-sub-menu>
            <el-sub-menu index="2">
              <template #title>
                <el-icon>
                  <Setting />
                </el-icon>系统设置
              </template>
              <el-menu-item-group>
                <el-menu-item index="2-1"><el-icon>
                    <Edit />
                  </el-icon>修改密码</el-menu-item>
              </el-menu-item-group>
  
            </el-sub-menu>
  
          </el-menu>
        </el-scrollbar>
      </el-aside>
  
      <el-container>
        <el-header style="text-align: right; font-size: 12px">
          <div class="toolbar">
            <el-dropdown>
              <el-icon style="margin-right: 8px; margin-top: 1px">
                <setting />
              </el-icon>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item>View</el-dropdown-item>
                  <el-dropdown-item>Add</el-dropdown-item>
                  <el-dropdown-item>Delete</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
            <span>Tom</span>
          </div>
        </el-header>
  
        <el-main>
          <router-view></router-view>
        </el-main>
        <el-footer>Footer</el-footer>
      </el-container>
    </el-container>
  </template>
  
  <script setup>
  
  </script>
  
  <style scoped>
  .logo {
    height: 50px;
    color: white;
    text-align: center;
    line-height: 50px;
    font-weight: bold;
  }
  
  .layout-container-demo {
    height: 100vh;
  }
  
  .el-header {
    position: relative;
    background-color: white;
    color: var(--el-text-color-primary);
    box-shadow: var(--el-box-shadow-light);
  
  }
  
  
  .layout-container-demo .el-aside {
    color: var(--el-text-color-primary);
    background: black;
  }
  
  .layout-container-demo .el-menu {
    border-right: none;
  }
  
  .layout-container-demo .el-main {
    padding: 0;
    box-shadow: var(--el-box-shadow-light);
    margin: 10px 0px;
  }
  
  .layout-container-demo .toolbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    right: 20px;
  }
  
  .el-footer {
    box-shadow: var(--el-box-shadow-light);
  }
  </style>

  

 

标签:el,VUE,center,views,color,笔记,学习,vue,import
From: https://www.cnblogs.com/Lvkang/p/18219685

相关文章

  • LLM 大模型学习必知必会系列(九):Agent微调最佳实践,用消费级显卡训练属于自己的Agent!
    LLM大模型学习必知必会系列(九):Agent微调最佳实践,用消费级显卡训练属于自己的Agent!SWIFT支持了开源模型,尤其是中小型模型(7B、14B等)对Agent场景的训练,并将loss-scale技术应用到agent训练中,使中小模型APICall能力更稳定,并支持使用单张商业级显卡进行Agent推理和部署,可以直接在生......
  • VUE学习笔记(九)
    登录数据数据验证,学习elementplus组件种页面数据验证UserLogin.vue页面<template><divclass="login"><divclass="body"><divclass="container"><h2>用户登陆</h2>......
  • 解决Vue3项目使用多个根标签提示[vue/no-multiple-template-root]The template root r
    报错截图检查原因第一步:检查是否安装了 Vetur 插件 第二步:左下角设置图标 ==》设置第三步:进入设置页面搜索eslint把Vetur的验证模板,取消勾选 Validatevue-htmlinusingeslint-plugin-vue第四步:将错误提示页面关掉然后重新打开,即可正常显示......
  • 《第二节》一、FreeRTOS学习笔记-任务创建和删除
    FreeRTOS的任务创建和删除1,任务创建和删除的API函数(熟悉)任务的创建和删除本质就是调用FreeRTOS的API函数一、任务创建动态创建任务:任务的任务控制块以及任务的栈空间所需的内存,均由FreeRTOS从FreeRTOS管理的堆中分配静态创建任务:任务的任务控制块以及任务的栈空间所需......
  • 最新扣子(Coze)实战教程:扣子的插件使用,完全免费,快来学习吧~
    ......
  • VUE学习笔记(六)
    数据添加、修改、watch监听和删除数据添加AddCategory.vue<template><el-dialogv-model="dialogVisible":title="dialogTitle"width="500":before-close="handleClose"><el-form:model="ruleFroms"......
  • vue3项目中 路由elementPlus当中的标签页结合封装
    在项目当中大家应该都有看到过,像标签页一样的面包屑吧,接下来我为大家介绍一下,主要组成部分:路由+组件库的标签页。ok就这么easy!!!它实现的方法也不难哦请看效果图ok,在中间实现思路与大家分享一下:主要是使用watch监听我们的route路由的变化,然后根据传递过来的路由信息,进行标签页......
  • VUE学习笔记(五)
    defineprops和torefs的使用用法,从父组件(Category.vue)向子组件(AddCategory.vue)传输数据Category.vue<template><el-cardclass="box-card"><template#header><divclass="card-header"><s......
  • vue前端页面搭建
    十、页面搭建学习10.1安装element在这里看一下有没有elementui,有就是下载成功了。10.2mainjs全局引入importElementUIfrom'element-ui';import'element-ui/lib/theme-chalk/index.css';Vue.use(ElementUI)10.3简单试用运行serve10.4页面布局(都可以直接查......
  • Prism框架与Microsoft.Extensions.DependencyInjection的集成使用笔记
    在现代的WPF应用开发中,Prism框架提供了强大的模块化、依赖注入和MVVM支持,而Microsoft.Extensions.DependencyInjection提供了简洁而功能强大的依赖注入机制。另外很重要的一点是Microsoft.Extensions.*或者第三方的Nuget基本会提供Microsoft.Extensions.DependencyInjection,那么......