javascript - vue-router怎么不能实现跳转呢
问题描述
根据文档的例子试了一下vue-router用在项目中,一进入首页的路径是test.administer/index,但是根据路由配置,不是应该进入首页后跳转到Login.vue这个组件的内容吗?我根据以下的配置,当前进入首页后,显示的是App.vue里面的内容。。
index.blade.php:
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>1</title> <!--styles--> <link rel='stylesheet' href='https://www.haobala.com/wenda/{{ asset(’css/app.css’) }}'></head><body> <p id='app'></p> <!--scripts--> <script src='https://www.haobala.com/wenda/{{ asset(’js/main.js’) }}'></script></body></html>
main.js:
import Vue from ’vue’import VueRouter from ’vue-router’import VueResource from ’vue-resource’import ElementUI from ’element-ui’import ’element-ui/lib/theme-default/index.css’Vue.use(VueRouter)Vue.use(ElementUI)Vue.use(VueResource)import App from ’./App.vue’import Home from’./components/Home.vue’import Login from’./components/Login.vue’const router = new VueRouter({ routes:[{ path: ’/index’, component: Login, children: [{ path: ’homepage’, component: Home} ]} ]})new Vue(Vue.util.extend({ router },App)).$mount(’#app’)
App.vue:
<template> <p id='app'><h1>hello world</h1><router-view></router-view> </p></template>
login.vue:
<template> <p>loginpage</p></template>
问题解答
回答1:你哪里有配置是 首页是 Login component 组件嘛
默认需要 /
routes:[{ path: ’/’, component: Login, children: [{ path: ’homepage’, component: Home} ]} ]
如果你配置成 /index
那么对应网址是
test.administer/index/#/index
test.administer/index/#/index/homepage
另外 app.vue 里面的 hello world 会始终显示的
回答2:没有看到你的login路由在哪里,路由的话<router-view></router-view>间的视图会跳,但外面的内容还是保留的。
回答3:{ path: ’homepage’, component: Home}应该是{ path: ’/homepage’, component: Home}
相关文章:
1. windows误人子弟啊2. php传对应的id值为什么传不了啊有木有大神会的看我下方截图3. python - linux 下用wsgifunc 运行web.py该如何修改代码4. python - oslo_config5. 关于mysql联合查询一对多的显示结果问题6. 实现bing搜索工具urlAPI提交7. 冒昧问一下,我这php代码哪里出错了???8. mysql优化 - MySQL如何为配置表建立索引?9. MySQL主键冲突时的更新操作和替换操作在功能上有什么差别(如图)10. 数据库 - Mysql的存储过程真的是个坑!求助下面的存储过程哪里错啦,实在是找不到哪里的问题了。
