javascript - vue-router怎么不能實(shí)現(xiàn)跳轉(zhuǎn)呢
問(wèn)題描述
根據(jù)文檔的例子試了一下vue-router用在項(xiàng)目中,一進(jìn)入首頁(yè)的路徑是test.administer/index,但是根據(jù)路由配置,不是應(yīng)該進(jìn)入首頁(yè)后跳轉(zhuǎn)到Login.vue這個(gè)組件的內(nèi)容嗎?我根據(jù)以下的配置,當(dāng)前進(jìn)入首頁(yè)后,顯示的是App.vue里面的內(nèi)容。。
index.blade.php:
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>1</title> <!--styles--> <link rel='stylesheet' href='http://www.aoyou183.cn/wenda/{{ asset(’css/app.css’) }}'></head><body> <p id='app'></p> <!--scripts--> <script src='http://www.aoyou183.cn/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>
問(wèn)題解答
回答1:你哪里有配置是 首頁(yè)是 Login component 組件嘛
默認(rèn)需要 /
routes:[{ path: ’/’, component: Login, children: [{ path: ’homepage’, component: Home} ]} ]
如果你配置成 /index
那么對(duì)應(yīng)網(wǎng)址是
test.administer/index/#/index
test.administer/index/#/index/homepage
另外 app.vue 里面的 hello world 會(huì)始終顯示的
回答2:沒(méi)有看到你的login路由在哪里,路由的話<router-view></router-view>間的視圖會(huì)跳,但外面的內(nèi)容還是保留的。
回答3:{ path: ’homepage’, component: Home}應(yīng)該是{ path: ’/homepage’, component: Home}
相關(guān)文章:
1. python - 獲取到的數(shù)據(jù)生成新的mysql表2. javascript - js 對(duì)中文進(jìn)行MD5加密和python結(jié)果不一樣。3. mysql里的大表用mycat做水平拆分,是不是要先手動(dòng)分好,再配置mycat4. window下mysql中文亂碼怎么解決??5. sass - gem install compass 使用淘寶 Ruby 安裝失敗,出現(xiàn) 4046. python - (初學(xué)者)代碼運(yùn)行不起來(lái),求指導(dǎo),謝謝!7. 為啥不用HBuilder?8. python - flask sqlalchemy signals 無(wú)法觸發(fā)9. python的文件讀寫(xiě)問(wèn)題?10. 為什么python中實(shí)例檢查推薦使用isinstance而不是type?
