Vue-路由器不工作
Vue-router is not working
我是 Vue 新手。我一直在尝试使用 Vue-Router 设置一个简单的路由。但是我有一个问题,我不知道为什么。
当我转到 url“http://localhost:8080/#/" but i could not see 'Login' when i go to the url "http://localhost:8080/#/login”时,我可以看到 'Dashboard' 消息。
谢谢
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>
App.vue
<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
大写了
我是 Vue 新手。我一直在尝试使用 Vue-Router 设置一个简单的路由。但是我有一个问题,我不知道为什么。
当我转到 url“http://localhost:8080/#/" but i could not see 'Login' when i go to the url "http://localhost:8080/#/login”时,我可以看到 'Dashboard' 消息。
谢谢
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>
App.vue
<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
大写了