美文网首页
zh-admin 项目新建

zh-admin 项目新建

作者: 张中华 | 来源:发表于2022-01-27 17:10 被阅读0次
npm init @vitejs/app
or
yarn create @vitejs/app

项目建好之后,发现会有一些报错

vite.config.js有报错

找不到模块“vite”或其相应的类型声明。ts(2307)


解决方案:
在最外层新建一个.d.ts文件,文件名貌似没有特殊要求,会自动识别,文件内容如下:
shims.d.ts
declare module '*.vue' {
  import { DefineComponent } from 'vue'
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
  const component: DefineComponent<{}, {}, any>
  export default component
}

declare module 'vite'
declare module '@vitejs/plugin-vue';

文件目录如下:


import HelloWorld from './components/HelloWorld.vue'报错:import HelloWorld from './components/HelloWorld.vue'

解决方法:
在设置中搜索vetur,找到 Vetur › Validation: Script
取消勾选 Validate js/ts in


参考地址

https://cn.vitejs.dev/guide/#scaffolding-your-first-vite-project
https://juejin.cn/post/6973288527802925092
https://www.cnblogs.com/JasmineHan/p/13673560.html

相关文章

网友评论

      本文标题:zh-admin 项目新建

      本文链接:https://www.haomeiwen.com/subject/ufaohrtx.html