Vue 记录!

Vue路由传值

<router-link :to="{name:'path',query:{id:44}}"></router-link>

路由接收值!

this.$route.query.id

Vue编程导航

this.$router.go(-1)前进后退

this.$router.push() 直接跳到某页面 可以传字符串或对象{name:'',query:{}}

重定向404处理

路由配置{path:'/',redirect:'/home'}

{path:'*',component:''}写在规则最后

 

多视图,多个坑位,这时候要用components为多个路由出口配置组件,路由出口没name属性时,用default代表

//html
<router-view name="header"></router-view>
<router-view ></router-view>
//js

import header from './header'
import body from './body'

new Router({
    routes:[
        {path:'/',components:{
                header:header,
                default:body
            }
        }
    ]
})

嵌套路由

注意点 嵌套路由子路由path配置时前面加/就变成绝对路径 不应该加
{
    path:'/',
    name:'home',
    component:home,
    children:[
        {path:'oumei',name:'oumei'},
        {path:'cuo',name:'guo'}
    ]
}

axios 使用

axios.defaults.baseURL='' //配置全局路径

this.$axios.get('/api',{header:{},params:{}}//params传参数

this.$axios.post('/api',{},{})

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值