当前位置:   article > 正文

vue3 element - plus 安装使用教程_vue3安装element-plus

vue3安装element-plus

下边是安装教程 element - plus   是针对 vue3  开发  

一个 Vue 3 UI 框架 | Element Plus (element-plus.org)icon-default.png?t=N7T8https://element-plus.org/zh-CN/

安装 element - plus  ui 库 

  1. # 选择一个你喜欢的包管理器
  2. # NPM
  3. $ npm install element-plus --save
  4. # Yarn
  5. $ yarn add element-plus
  6. # pnpm
  7. $ pnpm install element-plus

安装 element - plus icon 库  需要单独引入

  1. # 选择一个你喜欢的包管理器
  2. # NPM
  3. $ npm install @element-plus/icons-vue
  4. # Yarn
  5. $ yarn add @element-plus/icons-vue
  6. # pnpm
  7. $ pnpm install @element-plus/icons-vue

main.js   个人习惯 喜欢全局引入 

  1. import { createApp } from 'vue'
  2. import App from './App.vue'
  3. // 引入ui 库
  4. import ElementPlus from 'element-plus'
  5. import 'element-plus/dist/index.css'
  6. // 引入ui icon
  7. import * as ElementPlusIconsVue from '@element-plus/icons-vue'
  8. const app = createApp(App)
  9. for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  10. app.component(key, component)
  11. }
  12. app.use(ElementPlus)
  13. app.mount('#app')

 页面使用

  1. <template>
  2. <div class="bg">
  3. <div class="nav">
  4. <!-- 轮播图 -->
  5. <div class="block">
  6. <el-carousel trigger="click">
  7. <el-carousel-item v-for="item in 4" :key="item">
  8. </el-carousel-item>
  9. </el-carousel>
  10. </div>
  11. <!-- 表单 -->
  12. <div class="form">
  13. <h2 class="h2">欢迎登录</h2>
  14. <h6 class="p">左 右 软 件 后 勤 系 统 </h6>
  15. <el-form :model="ruleForm" :rules="rules" status-icon class="form-el">
  16. <el-form-item prop="name">
  17. <el-input v-model="ruleForm.name" placeholder="请输入账号" prefix-icon="User"/>
  18. </el-form-item>
  19. <el-form-item prop="pass">
  20. <el-input v-model="ruleForm.pass" placeholder="请输入密码" prefix-icon="Lock" show-password />
  21. </el-form-item>
  22. </el-form>
  23. <div class="form-but">
  24. <el-checkbox-group v-model="form.type">
  25. <el-checkbox label="记住密码" name="type" />
  26. </el-checkbox-group>
  27. <a href="https://www.baidu.com/" style="margin-left: 100px; text-decoration:none;">忘记密码?</a>
  28. </div>
  29. <el-button type="primary" style="width: 240px;margin-top: 250px;">登录</el-button>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { reactive } from 'vue'
  36. export default {
  37. name: 'HelloWorld',
  38. setup() {
  39. const form = reactive({
  40. type: [],
  41. })
  42. const ruleForm = reactive({
  43. name: '',
  44. pass: ''
  45. })
  46. const rules = reactive({
  47. name: [
  48. { required: true, message: '请输入账号', trigger: 'blur' },
  49. { min: 3, max: 5, message: '账号3到5位', trigger: 'blur' },
  50. ],
  51. pass: [
  52. { required: true, message: '请输入密码', trigger: 'blur' },
  53. { min: 3, max: 5, message: '账号3到5位', trigger: 'blur' },
  54. ],
  55. })
  56. return {
  57. ruleForm,
  58. rules,
  59. form
  60. }
  61. }
  62. }
  63. </script>
  64. <style setup>
  65. .form-but{
  66. display: flex;
  67. left: 30px;
  68. top: 230px;
  69. position: absolute;
  70. }
  71. .form-el{
  72. width: 250px;
  73. left: 34px;
  74. top: 120px;
  75. position: absolute;
  76. }
  77. .h2{
  78. left: 30px;
  79. top: 20px;
  80. position: absolute;
  81. }
  82. .p{
  83. left: 30px;
  84. top: 55px;
  85. position: absolute;
  86. color: rgb(172, 172, 172);
  87. }
  88. .form{
  89. right: 30px;
  90. top: -30px;
  91. border-radius: 5px;
  92. padding: 30px 20px;
  93. position: absolute;
  94. margin: auto;
  95. width: 300px;
  96. height: 312px;
  97. background: rgb(255, 255, 255);
  98. }
  99. .block {
  100. width: 420px;
  101. height: 300px;
  102. top: 0;
  103. bottom: 0;
  104. position: absolute;
  105. margin: auto;
  106. }
  107. .el-carousel__item:nth-child(2n) {
  108. background-image: url('../assets/logo.png') ;
  109. background-position: center center;
  110. background-repeat: no-repeat;
  111. }
  112. .el-carousel__item:nth-child(2n + 1) {
  113. background-image: url('../assets/logo.png') ;
  114. background-position: center center;
  115. background-repeat: no-repeat;
  116. }
  117. .bg {
  118. width: 100%w;
  119. height: 45rem;
  120. background: url('../assets/QQ截图20230904182803.jpg');
  121. }
  122. .nav {
  123. width: 900px;
  124. height: 420px;
  125. background: url('../assets/QQ截图20230904182803.jpg');
  126. left: 0;
  127. top: 0;
  128. right: 0;
  129. bottom: 0;
  130. position: absolute;
  131. margin: auto;
  132. }
  133. </style>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/121059
推荐阅读
相关标签
  

闽ICP备14008679号