vue路由配置
来源:互联网 发布:js烟花效果带文字 编辑:程序博客网 时间:2024/05/23 17:30
https://router.vuejs.org/zh-cn/
1.main.js
// The Vue build version to load with the `import` command// (runtime-only or standalone) has been set in webpack.base.conf with an alias.import Vue from 'vue'import App from './App'import VueRouter from 'vue-router'import goods from './components/goods/goods.vue'import ratings from './components/ratings/ratings.vue'import seller from './components/seller/seller.vue'Vue.use(VueRouter)Vue.config.productionTip = false// 2. 定义路由const routes = [ { path: '/goods', component: goods }, { path: '/ratings', component: ratings }, { path: '/seller', component: seller }]// 3. 创建 router 实例,然后传 `routes` 配置const router = new VueRouter({ routes // (缩写)相当于 routes: routes})// 4. 创建和挂载根实例。// 记得要通过 router 配置参数注入路由,// 从而让整个应用都有路由功能new Vue({ router, template: '<App/>', components: { App }}).$mount('#app')routes.push('goods')2.App.vue
<template> <div> <kheader> </kheader> <div class="tab"> <router-link to="/goods" class="tabItem">商品</router-link> <router-link to="/ratings" class="tabItem">评论</router-link> <router-link to="/seller" class="tabItem">商家</router-link> </div> <!-- 路由出口 --> <!-- 路由匹配到的组件将渲染在这里 --> <router-view></router-view> </div></template><script> import kheader from './components/vheader/kheader.vue' export default{ components: { kheader } }</script><style lang="stylus" rel="stylesheet/stylus"> .tab{ display flex width 100% height 40px } .tab .tabItem{ flex :1 text-align :center }</style>
阅读全文
0 0
- vue 路由配置1
- vue路由配置
- vue路由配置
- Vue配置路由
- vue嵌套路由配置
- vue动态路由配置
- Vue-Router的路由实例构造配置
- vue-cli 配置路由>>跳转传递参数
- vue-2.x webpack 安装vue-router 配置路由
- Vue路由
- vue 路由
- Vue路由
- Vue路由
- vue路由
- Vue-路由
- vue 路由
- vue路由
- vue路由
- 对开发者有用的英文网站清单
- [LintCode]67.二叉树的中序遍历
- js获取地理位置的经纬度
- PDO ping 的实例 ,解决mysql has gone的问题
- php5字符串函数总汇(方便查阅)
- vue路由配置
- 中钰睿泓分享:用户体验需要什么内容
- vyos bug
- Java线程锁,以及volatile、synchronized、Lock关键字
- UNIX环境编程学习笔记(5)——文件I/O之fcntl函数访问已打开文件的性质
- 详解numpy的argmax
- 用I/O完成端口+socket编写客户端demo实现Http下载
- JQuery简述
- 【hpu oj 1015 985的方格难题 [DP、数学] 】