vue3 vite 打包 二级目录刷新空白

控制台报错:Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

打包路径问题,修改vite.config.ts文件的base

export default defineConfig({
  plugins: [vue()],
  base: '/',    // 改为 根目录  /
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `@import "@/assets/css/index.less";`
      }
    }
  }
})

猜你喜欢

转载自blog.csdn.net/weixin_50587417/article/details/132764659