update vue guide

This commit is contained in:
梁伟林 2023-12-11 20:02:39 +08:00
parent 128c7dc95b
commit 0a2a4e915d

37
vue.md
View File

@ -15,7 +15,7 @@
<script setup>
<!-- ts -->
<script setup ts>
<script setup lang="ts">
```
* ##### 推荐使用Typescript/jsdoc开发
@ -38,4 +38,39 @@
```
* ##### 布局组件文件使用xxxLayout结尾命名
```
MainLayout
DeviceLayout
```
* ##### 页面文件使用xxxPage结尾命名
```
DevicePage
DeviceDetailPage
```
* ##### 路由定义每个页面必须带上唯一name通常与页面文件名一致页面跳转统一使用name切换不允许直接push路径方式
```
{
path: '/device',
name: 'DevicePage',
component: () => import('@/views/device/DevicePage.vue')
}
跳转到页面时使用router.push({name: 'DevicePage'})
```
* ##### 不同组件间的引用尽量使用@/views/xxx/xxx.vue的路径方式避免使用相对路径方式
```
import DevicePage from '@/views/device/DevicePage.vue'
有的项目为 src
import DevicePage from '@/views/device/DevicePage.vue'
```
* ##### 路由定义每个页面必须带上meta属性其中meta.title为页面标题meta.icon为页面图标meta.keepAlive为页面是否需要缓存
* ##### 待补充