专业IT网络知识平台,分享IT百科知识、生活百科知识解答!

易企推科技
易企推科技

element是什么,前端框架element Plus教程

来源:小易整编  作者:小易  发布时间:2023-03-22 05:28
摘要:element是什么,前端框架elementPlus教程说到好用的前端框架,就不得不提ElementPlus,今天给大家介绍一下ElementPlus的基本知识和用法。1、ElementPlus概念Element+是一款用于制作页面样式,设...

<template>  <div class="common-layout">    <el-container>      <el-aside width="200px">  <el-radio-group v-model="isCollapse" style="margin-bottom: 20px">    <el-radio-button :label="false">expand</el-radio-button>    <el-radio-button :label="true">collapse</el-radio-button>  </el-radio-group>  <el-menu    default-active="2"    class="el-menu-vertical-demo"    :collapse="isCollapse"    @open="handleOpen"    @close="handleClose"  >    <el-sub-menu index="1">      <template #title>        <el-icon><location /></el-icon>        <span>Navigator One</span>      </template>      <el-menu-item-group>        <template #title><span>Group One</span></template>        <el-menu-item index="1-1">item one</el-menu-item>        <el-menu-item index="1-2">item two</el-menu-item>      </el-menu-item-group>      <el-menu-item-group title="Group Two">        <el-menu-item index="1-3">item three</el-menu-item>      </el-menu-item-group>      <el-sub-menu index="1-4">        <template #title><span>item four</span></template>        <el-menu-item index="1-4-1">item one</el-menu-item>      </el-sub-menu>    </el-sub-menu>    <el-menu-item index="2">      <el-icon><icon-menu /></el-icon>      <template #title>Navigator Two</template>    </el-menu-item>    <el-menu-item index="3" disabled>      <el-icon><document /></el-icon>      <template #title>Navigator Three</template>    </el-menu-item>    <el-menu-item index="4">      <el-icon><setting /></el-icon>      <template #title>Navigator Four</template>    </el-menu-item>  </el-menu>      </el-aside>      <el-container>        <el-header>        <el-menu    :default-active="activeIndex2"    class="el-menu-demo"    mode="horizontal"    background-color="#545c64"    text-color="#fff"    active-text-color="#ffd04b"    @select="handleSelect"  >    <el-menu-item index="1">Processing Center</el-menu-item>    <el-sub-menu index="2">      <template #title>Workspace</template>      <el-menu-item index="2-1">item one</el-menu-item>      <el-menu-item index="2-2">item two</el-menu-item>      <el-menu-item index="2-3">item three</el-menu-item>      <el-sub-menu index="2-4">        <template #title>item four</template>        <el-menu-item index="2-4-1">item one</el-menu-item>        <el-menu-item index="2-4-2">item two</el-menu-item>        <el-menu-item index="2-4-3">item three</el-menu-item>      </el-sub-menu>    </el-sub-menu>    <el-menu-item index="3" disabled>Info</el-menu-item>    <el-menu-item index="4">Orders</el-menu-item>  </el-menu>        </el-header>                <el-main>Main</el-main>      </el-container>    </el-container>  </div></template><script lang="ts" setup>import { ref } from 'vue'import {  Document,  Menu as IconMenu,  Location,  Setting,} from '@element-plus/icons-vue'const isCollapse = ref(true)const handleOpen = (key: string, keyPath: string[]) => {  console.log(key, keyPath)}const handleClose = (key: string, keyPath: string[]) => {  console.log(key, keyPath)}const activeIndex2 = ref('1')const handleSelect = (key: string, keyPath: string[]) => {  console.log(key, keyPath)}</script><style>.el-menu-vertical-demo:not(.el-menu--collapse) {  width: 200px;  min-height: 400px;}</style>

觉得这个不好看没关系,后面我们会对这个页面进行一个自主DIY。首先我们先修改如下参数让他们的颜色统一:

active-text-color="#ffd04b"    background-color="#545c64"    text-color="#fff"

element是什么,前端框架element Plus教程

3.4.1、侧边栏优化
有些同学可能觉得这个按键不好看,希望修改一下其中的样式。
这边先展示一些代码,后面在完成vue的学习以后在来让大家完成对这块的改编。(使用v-if来判断目前状态展示按钮)

<el-radio-group v-model="isCollapse" style="margin-bottom: 20px">          <el-radio-button :label="false" v-if="isCollapse"            ><el-icon><fold /></el-icon>          </el-radio-button>          <el-radio-button :label="true" v-if="!isCollapse"            ><el-icon><expand /></el-icon          ></el-radio-button>        </el-radio-group>

上面代码需要在底下script中引入如下内容:

element是什么,前端框架element Plus教程

Fold,Expand,

3.5、主体内容增加:

Element+有两种模式,一种是你去做一个只有顶部导航栏和侧面导航栏的框体,其他内容通过vue直接渲染到主体。另一种是直接自己在主体中编写内容。
由于我们现在没接触过vue,所以我们先来尝试一下使用原生的代码实现一个主体页面编写。
我们先找到按钮这个位置:
element是什么,前端框架element Plus教程

找到我们喜欢的样式
注:下面那种带图标的按钮可能需要引入额外的Element-icon
我们先试试如下按钮:

<el-button type="warning">Warning</el-button>

把他放入我们的主体,也就是main里面:

<el-main>         <el-button type="warning" >Warning</el-button>        </el-main>

那么这个时候呢,有些同学可能想问,如果我不想要这个样式怎么办呢?
让我们来试一个东西:

<el-main>         <el-button type="warning" style="width:300px">Warning</el-button>        </el-main>

好!神奇的事情发生了,我们惊奇的发现按钮的样式发生了改变。也就是说这个框架是支持我们之前使用过的css引入模式的。
注:虽然可以使用css样式,但是禁止使用js的函数,功能。由于新版Element+集成的是TypeScript,所以使用JS会爆发冲突。后续注册事件可以使用vue方法来实现。

本文地址:IT百科频道 https://www.hkm168.com/tags/936285_3.html,易企推百科一个免费的知识分享平台,本站部分文章来网络分享,本着互联网分享的精神,如有涉及到您的权益,请联系我们删除,谢谢!

共3页 1 2 3 当前是最后一页

IT百科
小编:小易整编
相关文章相关阅读
  • 用U盘轻松实现一键重装系统的小白装机教程

    用U盘轻松实现一键重装系统的小白装机教程

    在现代社会,电脑已经成为人们生活中不可或缺的工具。然而,由于各种原因,我们有时候需要重装电脑系统来解决一些问题或提升性能。但是,对于一些小白用户来说,重装系统可能是一项困难的任务。因此,本文将介绍一款小白一键重装系统的u盘装机教程,帮助小白...

  • 前端开发需要哪些软件

    前端开发需要哪些软件

    编程一般用的软件有:1、hbuilder;2、sublimetext;3、webstorm;4、phpstudy;5、dreamweaver;6、visualstudio;7、phpstorm;8、notepad等等。孔子说,“工欲善其...

  • 什么是前端和后端

    什么是前端和后端

    什么是前端和后端?前端和后端哪个好?相信很多小白都会有这样的的问题,下面我们就来讲解一下前端和后端的区别是什么?什么是前端和后端?网站前端是对网页静态页面的设计,通俗的来说,就是我们肉眼能看的到的东西,当我们浏览网站的时候所看到的页面上的内...

  • 百度智慧课堂怎么使用?百度智慧课堂使用教程

    百度智慧课堂怎么使用?百度智慧课堂使用教程

    百度智慧课堂怎么使用?百度智慧课堂是一款可以再网上带给你丰富的线上学习服务的线上学习软件,很多名师教授在其中免费授课,是很多人在线提升自己的重要渠道,不过很多新用户并不懂得该如何正确使用该软件,下面就由小编为大家带来有关百度智慧课堂的使用教...

  • 解析如何解锁iPhone屏幕的教程,帮你解决手机被锁定的问题

    解析如何解锁iPhone屏幕的教程,帮你解决手机被锁定的问题

    你是否曾经遇到过忘记iphone的锁屏密码的情况?或者是否遭遇过熊孩子乱试密码导致iphone被锁定一个小时的情况呢?如果你曾经有类似的经历,需要快速解锁屏幕,那么可以考虑使用苹果屏幕解锁工具。这款工具是专为苹果用户设计的,可以帮助解锁苹果...

  • win7系统修复的详细教程

    win7系统修复的详细教程

    win7系统怎么修复呢?我们平时在使用电脑的过程中难免会遇到一些系统问题,有些系统问题比较严重,我们就需要对系统进行修复,修复系统的方法有不少,下面小编就跟大家分享一下win7系统修复的详细教程,感兴趣的小伙伴们快来看看吧!1、在开机启动的...

  • PHPChina学院Discuz基础视频教程资源分享

    PHPChina学院Discuz基础视频教程资源分享

    crossdaydiscuz!board(简称discuz!)是北京康盛新创科技有限责任公司推出的一套通用的社区论坛软件系统。自2001年6月面世以来,discuz!已拥有15年以上的应用历史和200多万网站用户案例,是全球成熟度最高...

  • 燕十八php视频教程:2023年最新燕十八php相关视频教程全集

    燕十八php视频教程:2023年最新燕十八php相关视频教程全集

    燕十八,原名刘道成,布尔教育教学总监。国内著名php培训讲师。燕十八和韩顺平以前为同事,都曾经在传智播客任php讲师。燕十八录制的php视频教程独特的“迭代式教学”方式,帮助众多编程爱好者,无痛苦入门编程,获得广大php学习者的喜爱!易企推...

  • 周排行
  • 月排行
  • 年排行

精彩推荐