zoukankan      html  css  js  c++  java
  • vue 路由 URL传参

    源码如下:

    import Vue from 'vue'
    import VueRouter from 'vue-router'
    
    Vue.use(VueRouter) //全局使用该组件
    
    const router = new VueRouter({
        mode:'history',
        base:__dirname,
        routes:[
            {
                path:'/'
            },
            {
                path:'/params/:aaa/:bbb' //绑定模板
            }
        ]
    })
    
    new Vue({
        router,
        template:`
            <div>
                <h1>Good Morning</h1>
                <ul>
                    <li><router-link to="/">/</router-link></li>
                    <li><router-link to="/params/111/222">/params/111/222</router-link></li>
                </ul>
                <p>show</p>
                <pre>
                    <code>
                        {{$route.params.bbb}}
                        {{JSON.stringify($route,null,2)}}
                    </code>
                </pre>
            </div>
        `
    }).$mount('#app')
  • 相关阅读:
    11.MySQL
    10、设计模式
    9
    8
    7
    6
    5
    4
    3
    2
  • 原文地址:https://www.cnblogs.com/candy-Yao/p/9365726.html
Copyright © 2011-2022 走看看