javascript - vue-cli搭建后如何加入新頁面
問題描述
我剛搭建好了vue-cli的結(jié)構(gòu)這個頁面已經(jīng)出來了,如果我想往下繼續(xù)添加幾個組件應(yīng)該怎么編輯,本人對router還不是特別熟,求指教
問題解答
回答1:使用vue-router配置路由 在vue根實例中注入
import Vue from ’vue’import VueRouter from ’vue-router’import topNav from ’../components/topNav’import mine from ’../components/mine’import searchPage from ’../components/searchPage’import searchResult from ’../components/searchResult’import playPage from ’../components/playPage’import playbottom from ’../components/playbottom’import latestPlay from ’../components/latestPlay’Vue.use(VueRouter)const router = new VueRouter({ routes: [{ path: ’/’, component: mine},{ path: ’/mine’, component: mine},{ path: ’/mine/searchPage’, component: searchPage},{ path: ’/mine/searchPage/searchResult’, component: searchResult},{ path: ’/playPage’, component: playPage},{ path: ’/latestPlay’, component: latestPlay} ]})export default router
import router from ’../router’var app = new Vue({ el: '#app1', router, store: vuex_store,})
大概就是這樣 鏈接用<router-link to='/play'></router-link>這樣 建議還是通過文檔學(xué)習(xí)
回答2:http://router.vuejs.org/zh-cn...參考文檔。。配置路由
相關(guān)文章:
1. 請教使用PDO連接MSSQL數(shù)據(jù)庫插入是亂碼問題?2. node.js - nodejs開發(fā)中常用的連接mysql的庫3. Python爬蟲如何爬取span和span中間的內(nèi)容并分別存入字典里?4. mysql - 分庫分表、分區(qū)、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處5. 視頻文件不能播放,怎么辦?6. python - 數(shù)據(jù)與循環(huán)次數(shù)對應(yīng)不上7. mysql - 把一個表中的數(shù)據(jù)count更新到另一個表里?8. 黑客 - Python模塊安全權(quán)限9. flask - python web中如何共享登錄狀態(tài)?10. mysql 查詢身份證號字段值有效的數(shù)據(jù)
