Working with VUE/VUEX. I want to import the Component "Popup.vue" from the file: "Tienda2.vue". But I am getting this error:
**Failed to compile.
./src/layouts/Tienda2.vue?vue&type=script&lang=js (./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./src/layouts/Tienda2.vue?vue&type=script&lang=js) Module not found: Error: Can't resolve '@/components/Popup.vuex' in 'D:\Cursos\VUE\0_proyecto\src\layouts'**
I'm pretty sure the import path is valid, here is my folder structure:
|----src
|----components
| |---------Popup.vue
|
|----layouts
|---------Tienda2.vue
I have tried with @/components/Popup.vuex and ../components/Popup.vuex. Here is my code:
Tienda2.vue
<template>
<h1>Tienda2 {{id}}</h1>
**<Popup />**
<div class="about">
<h4 v-for="tipo in tipoArticulo" :key="tipo.nombre">
<div @click="$router.push({name:'TipoArticulo', params: {id:`${tipo.nombre}`}})">{{tipo.nombre}}</div>
</h4>
</div>
<router-view></router-view>
</template>
<script>
import {mapState} from 'vuex'
**import Popup from '@/components/Popup.vuex'**
export default {
components: {
**Popup**
},
props:{
id: {
type: String,
required: true
}
},
computed: {
...mapState(['tipoArticulo'])
},
created() {
this.$router.push({name: 'TipoArticulo', params: { id: 'Láminas' }})
}
}
</script>```
[1]: https://i.stack.imgur.com/lJZlE.png
[2]: https://i.stack.imgur.com/5Hx7H.png
CodePudding user response:
It should be '.vue', not 'vuex'.
import Popup from '../components/Popup.vue'