基于vue-cli的vue项目之路由6--重定向4-----path带参重定向
来源:互联网 发布:苹果手机数据恢复软件免费版 编辑:程序博客网 时间:2024/05/29 08:35
不过很遗憾,这种方式我个人,请注意,是我个人因为技术不够,无法在页面初始化的时候带参数,可能可以实现这种方法吧。。。
1.hello.vue子界面:用来显示所传参数的子界面<template><div class="hello"><h1>这个是hello.vue页面</h1><h2>{{$route.params.hparams1}}</h2></div></template><script>export default {name: 'hello',}</script>2.router/index.js:路由配置文件,关键在于第十九到第二十六行import Vue from 'vue'import VueRouter from 'vue-router'Vue.use(VueRouter)const router = new VueRouter({routes: [{path: '/hello:hparams1',component: require('../components/Hello.vue'),},{path: '/foo:hparams1',redirect: '/hello:hparams1'},]})export default router;3.app.vue:主界面<template><div id="app"><!-- <hello></hello> --><div class="nav"><ul><li><router-link to="/hello123">hello页面</router-link></li><li><router-link to="/foo123">foo页面</router-link></li></ul></div><div class="main"><router-view></router-view></div></div></template><script>export default {name: 'app',components: {},}</script><style>body {background-color: #f8f8ff;font-family: 'Avenir', Helvetica, Arial, sans-serif;color: #2c3e50;}.nav {position: fixed;width: 108px;left: 40px;}.nav ul {list-style: none;margin: 0;padding: 0;}.nav ul li {width: 108px;height: 48px;line-height: 48px;border: 1px solid #dadada;text-align: center;}.nav ul li a {display: block;position: relative;text-decoration: none;}.nav ul li img {position: absolute;left: 0;top: 0;width: 100px;height: 30px;}.main {height: 400px;margin-left: 180px;margin-right: 25px;}</style>main.js:配置路由路径import Vue from 'vue'import App from './App'import VueRouter from 'vue-router'import router from './router'Vue.use(VueRouter);new Vue({el: '#app',router,render: h => h(App)})效果如下:
阅读全文
1 0
- 基于vue-cli的vue项目之路由6--重定向4-----path带参重定向
- 基于vue-cli的vue项目之路由6--重定向1-----path无参重定向
- 基于vue-cli的vue项目之路由6--重定向2-----页面初始化重定向
- 基于vue-cli的vue项目之路由6--重定向1-----路径无参重定向
- 基于vue-cli的vue项目之路由6--重定向3-----method返回重定向路径
- vue-cli 路由重定向
- 基于vue-cli的vue项目之路由4--嵌套路由
- 基于vue-cli的vue项目之路由3--watch监听路由
- Vue路由重定向(第一次写博客)
- 基于vue-cli的vue项目之路由1--最基本的使用
- 基于vue-cli的vue项目之路由2--param传参
- 基于vue-cli的vue项目之路由5--router.push,go,replace方法
- vue重定向
- 基于vue-cli的vue项目之axios的使用6--配置axios
- 基于vue-cli的vue项目之axios的使用4--并发请求
- 基于vue-cli的vue项目之vuex的使用4-------moudles分块
- Vue路由(vue-router)配置实战——动态路由,重定向,工程非根目录
- 基于vue-cli的vue项目之axios的使用2--最基础的请求
- PHP微信简单分享组件
- 交换变量
- win7网络打印机重启后脱机的问题
- 公司实施odoo(openerp)Ubuntu14.04安装过程,实施成功!
- react-router 中的history
- 基于vue-cli的vue项目之路由6--重定向4-----path带参重定向
- [Leetcode] 396. Rotate Function 解题报告
- kylin创建cube时的步骤及一些notes
- 服务器上的内容无法复制到本机
- 当你输入一个网址的时候,实际会发生什么
- Ajax data数据格式
- “封装”的简单实现
- MySQL数据库TDSQL架构分析及采用策略扩容流程
- LeetCode--Insert Interval