簡體   English   中英

Vue路由器不起作用

[英]Vue-router is not working

我是Vue新手。 我一直在嘗試使用Vue-Router設置簡單的路由。 但是我有一個問題,就是我不知道為什么。

我能看到的“儀表盤”的消息,當我去到URL“ HTTP://本地主機:8080 /#/ ”,但我看不到“登錄”當我去到URL“ HTTP://本地主機:8080 /# / login “。

謝謝

index.js

import Vue from 'vue'
import Router from 'vue-router'
import Dashboard from '@/components/Dashboard'
import Login from '@/components/Login'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: Dashboard
    },
    {
      path: '/login',
      Component: Login
    }
  ]
})

Login.vue

<template>
    <p>Login</p>
</template>

<script>
  export default {}
</script>

應用程序

<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
export default {}
</script>

Dashboard.vue

<template>
    <p>Dashboard</p>
</template>

<script>
  export default {
    name: 'Dashboard'
  }
</script>

我不是Vue專家,但是我覺得您應該導航到localhost:8080/login而不是localhost:8080/#/login

您還已在index.js的第16行中將Component大寫

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM