967 B
967 B
name, description
| name | description |
|---|---|
| app-development | 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
<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>