V
V
vladislav9972020-09-12 17:25:32
Vue.js
vladislav997, 2020-09-12 17:25:32

Why does vue duplicate index?

Such a question, I’m just starting to study vue (spa), but for some reason the App is duplicated 2 times (first screen):
5f5cd9cdbedc0944845367.png
5f5cd9d2edf6a756442504.png
and the rest of the routes work fine.

main.js:

import Vue from 'vue'
import App from './App'
import About from './components/About'
import Request from './components/Request'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const routes = [
  { path: '/', component: App },
  { path: '/about', component: About },
  { path: '/request', component: Request }
]

const router = new VueRouter({
  routes
})

new Vue({
  el: '#app',
  template: '<App/>',
  components: { App },
  router
}).$mount('#app')

and app.vue:
<template>
  <div id="app">
    <!-- здесь будут отображаться наши компоненты -->
    <router-link to="/">Home</router-link>
    <router-link to="/about">About</router-link>
    <router-link to="/request">Request</router-link>
    <router-view></router-view>
  </div>
</template>

<script>
  export default {
    name: 'app',
  }
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-09-12
@vladislav997

Because you are using the App component twice - as the root application component, and as a route component.
Remove , or specify some other component instead of App. { path: '/', component: App },

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question