Blogger Information
Blog 62
fans 3
comment 1
visits 29722
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
vue二级路由-路由守卫-组合api
kiraseo_wwwkiraercom
Original
405 people have browsed it

vue 二级路由

效果

在二级路由利用路由守卫监听效果

组合api

代码如下

  1. <template>
  2. <nav>
  3. <router-link to="/">首页</router-link> |
  4. <router-link to="/about">关于我们</router-link>
  5. </nav>
  6. <router-view />
  7. <div>{{data.num}}</div>
  8. <button @click="fun">点赞</button>
  9. </template>
  10. <script setup>
  11. import { reactive } from "vue";
  12. const data = reactive({
  13. num : 100
  14. })
  15. const fun = () =>{
  16. data.num++;
  17. }
  18. </script>
  19. <style lang="scss">
  20. #app {
  21. font-family: Avenir, Helvetica, Arial, sans-serif;
  22. -webkit-font-smoothing: antialiased;
  23. -moz-osx-font-smoothing: grayscale;
  24. text-align: center;
  25. color: #2c3e50;
  26. }
  27. nav {
  28. padding: 30px;
  29. a {
  30. font-weight: bold;
  31. color: #2c3e50;
  32. &.router-link-exact-active {
  33. color: #42b983;
  34. }
  35. }
  36. }
  37. </style>

效果

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post