vue - "navigation routing query programming pass value

1. Now a Page Setup button

<Template> 
    <div> 
        <Button @ the Click = "handleToRouter"> route by value </ Button> 
    </ div> 
</ Template> 

<Script> 
    Export default { 
        Components: { 
            
        }, 
        Data () { 
            return { 
            } 
        }, 
        Methods: { 
            handleToRouter () { 
                the this $ router.push ({. 
                    path: "/ D", // jump path 
                    query: {n: "I am a", b: "I b"} // pass value 
                }) 
            } 
        }, 
    } 
</ Script>

  2. In another page by value

<template>
    <div>

    </div>
</template>

<script>
    export default {
        watch: {
            //监听路由
            $route(val){
               console.log(val,"333333333333333")
            },
        },
        data() {
            return {
                routerVal: this.$route.query
            }
        },
        mounted () {
            console.log(this.routerVal);
        },
    }
</script>

 

Guess you like

Origin www.cnblogs.com/wangqi2019/p/11495504.html