javascript - vue-cli搭建后如何加入新頁面
問題描述
我剛搭建好了vue-cli的結構
這個頁面已經出來了,如果我想往下繼續添加幾個組件應該怎么編輯,本人對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>這樣 建議還是通過文檔學習
回答2:http://router.vuejs.org/zh-cn...參考文檔。。配置路由
相關文章:
1. javascript - sublime快鍵鍵問題2. javascript - immutable配合react提升性能?3. vue.js - Vue 如何像Angular.js watch 一樣監聽數據變化4. 配置Apache時,添加對PHP的支持時語法錯誤5. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~6. javascript - nodejs關于進程間發送句柄的一點疑問7. javascript - 移動端上不能實現拖拽布局嗎?8. phpstudy8.1支持win11系統嗎?9. 實現bing搜索工具urlAPI提交10. Apache 已經把網站根目錄的改為allow from all了,但是服務器還是不能訪問?

網公網安備