Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

623
Visualizações
plugin:vite:import-analysis: Failed to resolve import "../../views/main/index" from "src/router/module/mobile-routes.js". Does the file exist?

In my Vue JS application, I have the following js inside src/router index.js

import { createRouter, createWebHistory } from 'vue-router'
import { isMobileTerminal } from '../utils/flexible'
import mobileRoutes from './module/mobile-routes'
import pcRoutes from './module/pc-routes'

// 创建 vueRouter实例
const router = createRouter({
  history: createWebHistory(),
  routes: isMobileTerminal.value ? mobileRoutes : pcRoutes
})

export default router

And I have the following mobile-routes.js inside src/router/module

export default [
  {
    path: '/', // 路径
    name: 'home', // 当前路由名字
    component: () => import('../../views/main/index') // 对应的组件
  }
]

Then I have a component called, index.vue inside src/views/main

<template>
  <div>
    移动端首页
  </div>
</template>

<script setup>
export default {
  name: 'index'
}
</script>

<style lang="scss" scoped></style>

Every time I tried to run my application, it kept giving me the following errors: [plugin:vite:import-analysis] Failed to resolve import "../../views/main/index" from "src/router/module/mobile-routes.js". Does the file exist?

ERROR as shown in the figure enter image description here

I'm using tailwind CSS ,vite and Vue 3

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The error is caused by vite,need to add a suffix, that is .vue in vite. Alter mobile-routes.js inside src/router/module

export default [
  {
    path: '/', // 路径
    name: 'home', // 当前路由名字
    component: () => import('../../views/main/index.vue') // 对应的组件
  }
]

I find the right answer at this websiteenter link description here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda