🎉 欢迎,我的Github主页.

文章

通过pnpm安装、管理node版本

安装 要安装最新的长期支持(LTS)版本: pnpm env use --global lts 要安装特定版本(例如 Node.js 16): pnpm env use --global 16 要安装最新的当前版本:

了解更多◥

在Nuxt Content项目中无意间发现的一个TS导包规则Bug

请看VCR // 报错的写法: import { type ArticlesEnCollectionItem } from '@nuxt/content' // 不报错的写法: import type { ArticlesEnCollectionItem } from '@nuxt/content' 报错内容 [15:28:01] ERROR Pre-transform error: Importing directly from module entry-points is not allowed. [importing @nuxt/content from src/pages/about/news/components/CardNewsInfo/index.vue] Plugin: vite:import-analysis File: D:/xxx/src/pages/about/news/components/CardNewsInfo/index.vue:64:48 7 | import { useModel as _useModel, defineComponent as _defineComponent } from "vue"; 8 | import { useImage } from "@vueuse/core"; 9 | import {} from "@nuxt/content"; | ^ 10 | 11 | import { useI18n } from 'vue-i18n'; Nuxt官方文档AI答复 import { type X } from '...' 和 import type { X } from '...' 在 TypeScript 里语义接近,但对打包器Vite来说并不完全一样。

了解更多◥

在Nuxt项目的ts文件中使用i18n

定义工具函数 ./src/composables/useT.ts/** * 在ts文件中使用国际化 * @param key 键名 * @param params 参数 * @returns 结果字符串 */ export const useT = (key: string, params?: Record<string, unknown>) => { const { $i18n } = useNuxtApp() return computed(() => $i18n.t(key, params || {})).value } 使用 useT('message.demo') useT('message.demo', { demoKey: 20 })

了解更多◥