vite搭建项目时引入ref时vue报红

315 阅读1分钟

使用create vite选了typescript后,在.vue文件中引入ref时 'vue' 报红

具体报错为: Cannot find module 'vue'. Did you mean to set the 'moduleResolution' option to 'node', or to add aliases to the 'paths' option?

如下图: image.png

解决办法:在tsconfig.json文件中找到compilerOptions下的moduleResolution,将moduleResolution的值'bundler'改为'node'。