url parameter variable configuration in axios

First configure the route profile

Variable preceded: so can pass arguments to the corresponding components

{
            path:'/user/:name',
            name:'user_info',
            component:UserInfo
        },

In the respective component, to pick up the data write method axios

getUser(){
            Axios.get(`https://cnodejs.org/api/v1/user/${this.$route.params.name}`)
            .then(response=>{
                window.console.log(response)
            })
        }

Note: The variable parameters are `backtick package

Guess you like

Origin www.cnblogs.com/raonet/p/11590268.html