Files
2026-07-13 21:35:40 +08:00

45 lines
967 B
Markdown

---
name: app-development
description: Vue/Nuxt/UnoCSS 应用开发约定。用于构建 Web 应用、在 Vite 与 Nuxt 之间做选择、或编写 Vue 组件时参考。
---
# 应用开发
## 框架选择
| 使用场景 | 选择 |
|----------|------|
| SPA、纯客户端、库的 playground | Vite + Vue |
| SSR、SSG、SEO 关键场景、基于文件的路由、API 路由 | Nuxt |
## Vue 约定
| 约定项 | 推荐做法 |
|--------|----------|
| 脚本语法 | 始终使用 `<script setup lang="ts">` |
| 状态 | 优先使用 `shallowRef()` 而非 `ref()` |
| 对象 | 使用 `ref()`,避免使用 `reactive()` |
| 样式 | UnoCSS |
| 工具库 | VueUse |
### Props 与 Emits
```vue
<script setup lang="ts">
interface Props {
title: string
count?: number
}
interface Emits {
(e: 'update', value: number): void
(e: 'close'): void
}
const props = withDefaults(defineProps<Props>(), {
count: 0,
})
const emit = defineEmits<Emits>()
</script>