vue3项目学习二:搭建项目架构

搭建项目架构

一、 初始化项目结构

  1. App.vue初始化
javascript 复制代码
<template>
  <router-view />
</template>

<style lang="scss"></style>
  1. 删除views文件夹中所有.vue文件
  2. 删除components文件夹下所有.vue文件
  3. 初始化router/index.js中的代码
javascript 复制代码
import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [

]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router

二、导入element-ui

element-ui对应vue3的版本为element-plus

  1. 通过vue-cli导入

vue add element-plus

  1. 选择全局导入


    等待安装完成

    注意安装完成后element会修改App.vue,此时如果启动会报错,所以先把App.vue恢复后再启动。
    或按照element官网进行安装。

三、搭建登陆架构

3.1 登陆页面

3.2 美化登陆页面样式

初始化全局style

  1. 在src创建styles/index.scss
css 复制代码
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;text-rendering: optimizeLegibility;
  font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,Microsoft YaHei,Arial, sans-serif;
}
#app {
  height: 100%;
}

*,
*:before,
*:after {
  box-sizing: inherit;
  margin:0;
  padding:0;
}

a:focus,
a:active {
  outline: none; 
}

a,
a:focus,
a:hover {
  cursor: pointer;
  color: inherit;
  text-decoration: none;
}

div:focus {
  outline: none;
} 

.clearfix {
  &:after {
    visibility: hidden;
    display: block;
    font-size: 0 ;
    content: '';
    clear: both;
    height: 0;
  }
}
  1. 在main.js中导入

import '@/styles/index.scss'

3.3 封装SVG组件

为了方便使用外部svg图标和element图标,这里选择封装一个svg组件,可以统一使用能够用到的所有svg图标。

暂时没有用到,且较麻烦,过几天更新svg相关

相关推荐
The_Killer.1 小时前
格密码--从FFT到NTT(附源码)
学习·线性代数·密码学·格密码
四谎真好看1 小时前
Java 黑马程序员学习笔记(进阶篇6)
java·笔记·学习·学习笔记
Alice-YUE2 小时前
【css学习笔记8】html5css3新特性
css·笔记·学习
有谁看见我的剑了?3 小时前
k8s-Sidecar容器学习
学习·容器·kubernetes
沐墨专攻技术3 小时前
二、网页的“化妆师”:从零学习 CSS
css·笔记·学习
g_i_a_o_giao3 小时前
Android8 binder源码学习分析笔记(四)——ServiceManager启动
笔记·学习·binder
GilgameshJSS3 小时前
【学习K230-例程23】GT6700-音频FFT柱状图
python·学习·音视频
今天我要乾重生4 小时前
泛型的学习
学习
前端码虫4 小时前
2.9Vue创建项目(组件)的补充
javascript·vue.js·学习
PigeonGuan5 小时前
强化学习中重要性采样
学习