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. 网页爬虫 - Python:爬虫的中文编码问题?2. javascript - vue生成一维码?求助!!!!!急3. javascript - H5页面怎么查看console信息?4. thinkjs - 使用mysql搭建cms应该如何设计表?或怎样开始?5. thread - Android 主线程更新UI问题6. javascript - 关于Js中 this的一道题7. css - 手机页面在安卓和苹果浏览器显示不同的小小问题8. javascript - 修改表单多选项时和后台同事配合的问题。9. javascript - jqery ajax问题10. ubuntu 远程管理KVM设置问题
