# vueAdminStudy
**Repository Path**: caihua1024/vue-admin-study
## Basic Information
- **Project Name**: vueAdminStudy
- **Description**: No description available
- **Primary Language**: JavaScript
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 1
- **Forks**: 0
- **Created**: 2025-05-02
- **Last Updated**: 2025-10-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
NPM安装与配置全流程详解(2025最新版
https://blog.csdn.net/weixin_62818371/article/details/146175470
删除vue3项目创建原始内容
验证项目
```
npm i
npm run dev
```
安装必要依赖
```
npm install less vue-router element-plus @element-plus/icons-vue
```
设置@别名,在vite.config.ts下
```
export default defineConfig({
plugins: [vue()],
//这个resolve是添加的别名
resolve:{
alias:[
{
find: "@", replacement: "/src"
}
]
}
})
```
引入重置样式文件和图片资源
把课件中的less文件夹和images文件夹,都放到src下的assets中
在main.ts中引入
```
import '@/assets/less/index.less'
```
#路由的创建
1.在src下创建router文件夹,在其中创建index.js文件
~~~js
//引入两个方法,第一个创建路由器对象,第二个是开启hash模式的方法
import { createRouter, createWebHashHistory } from 'vue-router'
//路由规则
const routes = [
{
path: '/',
name: 'main',
component: () => import('@/views/Main.vue')
}
]
const router = createRouter({
//history设置路由模式
history: createWebHashHistory(),
routes
})
//把路由器暴露出去
export default router
~~~
2.在src下创建views文件夹,并在其中创建Main.vue(组件需要默认的代码,不然会报错)
~~~js
我是main组件
~~~
3.在main.js中 使用路由,这里我们把createApp(App)用一个变量接收
~~~js
import router from './router'
const app =createApp(App)
app.use(router).mount('#app')
~~~
4.在app.vue组件中放置路由出口
~~~js
//这个是app的样式,设置全屏展示,防止滚动条的出现
//注意,style上不要使用scoped
~~~
#整体布局的实现
引入element-plus和@element-plus/icons-vue
文档:
element-plus:https://element-plus.org/zh-CN/guide/quickstart.html#%E5%AE%8C%E6%95%B4%E5%BC%95%E5%85%A5
@element-plus/icons-vue:https://element-plus.org/zh-CN/component/icon.html#%E6%B3%A8%E5%86%8C%E6%89%80%E6%9C%89%E5%9B%BE%E6%A0%87
~~~js
//这里ElementPlus我们使用完整引入
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
app.use(ElementPlus)
//注册@element-plus/icons-vue图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
~~~