<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue-router之路由参数的验证处理保存路由安全</title>
    <script src="vue.js"></script>
    <script src="vue-router.js"></script>
</head>
<body>
<div >
    <router-link to="/content">链接</router-link>
    <br/>
    <router-view></router-view>
</div>
<script type="text/x-template" >
    <div>
        id:{{$route.params.id}}
        <br/>
        <button @click="show">点击效果</button>
    </div>
</script>
<script>
    const content = {
        template: "#content",
        methods: {
            show() {
                console.log(this.$route.params);
            }
        }
    }
    let routes = [
        {path: '/content/:id(\\d{2})', component: content}
    ]
    let router=new VueRouter({routes});
    new Vue({
        el: "#demo",
        router
    });
</script>
</body>

</html>

  

相关文章:

  • 2022-02-08
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
  • 2021-08-22
  • 2021-05-20
  • 2022-12-23
猜你喜欢
  • 2021-09-03
  • 2021-09-23
  • 2022-12-23
  • 2021-12-03
  • 2021-12-15
  • 2021-07-11
  • 2021-05-22
相关资源
相似解决方案