题目描述
为什么我的导航始终返回localhost:8080/
其他所有路径都返回这个
有没有大佬指点一下
题目来源及自己的思路
官网的文档看了好几遍,始终不能理解。。
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
import Vue from 'vue'
import App from './App.vue'
import Router from "vue-router"
Vue.use(Router)
const ItWorks = {
template: '<div>It works!</div>'
}
const ItWorks_a = {
template: '<div>It works! hahahaha </div>'
}
const routes = [{
path: "/test",
name: "home",
component: ItWorks
},
{
path: "/",
name: "home2",
component: ItWorks_a
}
]
const router = new Router({
routes: routes
})
Vue.config.productionTip = false
new Vue({
el: '#app',
render: h => h(App),
router: router
})
你期待的结果是什么?实际看到的错误信息又是什么?
问题描述
http://localhost:8080/testt#/
http://localhost:8080/
都返回的是
http://localhost:8080/
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
把routes里两项的顺序调换一下试试。`const routes = [
{
path: "/",
name: "home2",
component: ItWorks_a
},
{
path: "/test",
name: "home",
component: ItWorks
}
]`