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

VUE学习笔记(二)

时间:2024-05-27 14:24:42浏览次数:12  
标签:box el vue name 笔记 学习 VUE router import

本小节为搭建布局页和分类页面

需要使用到element-plus,添加指令

npm install element-plus --save

布局页从elementplus官网找到布局,粘贴过来

<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>
<!-- 全局样式 -->
<style>
.card-header {
display: flex;
justify-content: flex-start;
align-items: center;
gap: 10px;
}

.text {
font-size: 14px;
}

.item {
margin-bottom: 18px;
}

.box-card {
width: 100wh;
height: 100vh;
}
</style>

 

src下的main.js添加elementplus和icon的注册

import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import "element-plus/dist/index.css";
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const app=createApp(App)
//icon注册
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }
app.use(ElementPlus).use(store).use(router).mount("#app");

src的router文件夹下添加路由category

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

const routes = [
  {
    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')
  }
]

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

export default router

 

src的views下新建文件CategoryView.vue

<template>
    <el-card class="box-card">
        <template #header>
            <div class="card-header">
                <span>商品分类</span>
                <el-button type="primary" icon="CirclePlus" round>添加分类</el-button>
            </div>
        </template>
        <el-table :data="tableData" stripe style="width: 100%">
            <el-table-column prop="id" label="Id" width="180" />
            <el-table-column prop="name" label="名称" width="180" />
            <el-table-column fixed="right" label="操作" width="180">
                <template #default>
                    <el-button  type="success" size="small" >
                        修改
                    </el-button>
                    <el-button  type="danger" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>

    </el-card>
</template>

<script setup>
const tableData = [
    {
        date: '2016-05-03',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
    {
        date: '2016-05-02',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
    {
        date: '2016-05-04',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
    {
        date: '2016-05-01',
        name: 'Tom',
        address: 'No. 189, Grove St, Los Angeles',
    },
]
</script>

 

标签:box,el,vue,name,笔记,学习,VUE,router,import
From: https://www.cnblogs.com/Lvkang/p/18215385

相关文章

  • 【SHELL】命令使用笔记
    按行拼接两个文件awk'NR==FNR{a[NR]=$0;next}{print$0,a[FNR]}'B.txtA.txt>C.txt注:文件格式须为unix,dos格式拼接后会跨行 在指定格式的文件中查找字符串在指定格式的文件中查找字符串grep-nr"string"--include=*.{c,cpp,h}在排除指定格式的文件中查找字符串grep......
  • 基于SpringBoot+Vue的实验室管理系统设计与实现毕设(文档+源码)
            目录一、项目介绍二、开发环境三、功能介绍四、核心代码五、效果图六、源码获取:        大家好呀,我是一个混迹在java圈的码农。今天要和大家分享的是一款基于SpringBoot+Vue的实验室管理系统,项目源码请点击文章末尾联系我哦~目前有各类成品......
  • 基于SpringBoot+Vue的火车订票管理系统设计与实现毕设(文档+源码)
            目录一、项目介绍二、开发环境三、功能介绍四、核心代码五、效果图六、源码获取:        大家好呀,我是一个混迹在java圈的码农。今天要和大家分享的是一款基于SpringBoot+Vue的火车订票管理系统,项目源码请点击文章末尾联系我哦~目前有各类成品......
  • PostScript学习心得
    TableofContents1.语句表达是逆波兰式2.一些特别的符号3.函数和过程可以看作C语言中的宏4.执行脚本可以看作解析流的过程5.栈平衡6.调试7.中文字体8.指令隐含的对栈的影响9.示例程序网上有PostScript的教程,并且还有参考手册,这里只是记录在学习该......
  • 【学习】智算中心案例组网认知
    智算中心网络延迟解决方案一、智算中心简介智算中心是一个集成高性能计算(HPC)、人工智能(AI)和大数据分析的综合平台,旨在提供强大的计算能力和数据处理能力,以支持各种复杂的计算任务和应用。二、网络延迟的重要性网络延迟是指数据从一个节点传输到另一个节点所需的时间。在......
  • scala完整笔记-5万字一周入门到精通系列(一)
    scala完整笔记-5万字一周入门到精通写在开篇1.scala学习前一定要具备了解一些java基本知识,无需精通;如果从未接触java,最好熟悉一门编程语言,否则相对还是学习起来相对吃力且很难学懂2.本篇主要以代码示例为主,很多概念理论并没有展开很多篇幅,毕竟......
  • FFmpeg开发笔记(二十四)Linux环境给FFmpeg集成AV1的编解码器
    ​AV1是一种新兴的免费视频编码标准,它由开放媒体联盟(AllianceforOpenMedia,简称AOM)于2018年制定,融合了GoogleVP10、MozillaDaala以及CiscoThor三款开源项目的成果。据说在实际测试中,AV1标准比H.265(HEVC)的压缩率提升了大约27%。由于AV1具有性能优势,并且还是免费授权,因此各大流......
  • Java学习【面向对象综合练习——实现图书管理系统】
    Java学习【面向对象综合练习——实现图书管理系统】前期效果图书的创建用户的创建操作的实现完善操作显示图书查找图书新增图书借阅图书归还图书删除图书前期效果用户分为普通用户和管理员,登录进系统之后可以对图书进行一系列操作,此时我们要明白,对图书的操作是通过......
  • Keras深度学习框架第二十八讲:可视化超参数调优过程
    1、绪论可视化超参数调优过程(Visualizethehyperparametertuningprocess)指的是在机器学习或深度学习的模型训练中,通过图形化或可视化的方式展示和调整模型的超参数(hyperparameters)。这个过程有助于用户直观地理解超参数如何影响模型的性能,从而找到最优的超参数设置。可......
  • vue测试环境打包文件不添加hash和生产环境打包不一致
    npmrunbuild:testnpmrunbuild:pro测试环境打包出来文件和生产包有差异.env.test-配置文件打包出来文件有hash值,加上下面的配置,打包就和pro一致NODE_ENV='production'NODE_ENV只能设置production和development两个参数开发环境是development,生产环境都是produ......