当前位置:   article > 正文

Vue3+Vite报错:vite忽略.vue扩展名 Failed to resolve import ..... Does the file exist?_vue . does the file exist

vue . does the file exist

Vue3+Vite报错:vite忽略.vue扩展名 Failed to resolve import … Does the file exist?

先看报错:

在这里插入图片描述

分析原因

原因是我们没有写后缀名 建议你在你的vite.config.js中加上如下配置

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  // resolve: {
  //   // 忽略后缀名的配置选项, 添加 .vue 选项时要记得原本默认忽略的选项也要手动写入
  //   extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  // },
});

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/728268
推荐阅读
相关标签
  

闽ICP备14008679号