Blogger Information
Blog 47
fans 0
comment 0
visits 21060
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
简单路由配置
P粉036614676
Original
399 people have browsed it

1、二级路由配置

  1. 1. 导入文件
  2. import Info from '../views/Info.vue';
  3. import Config from '../views/Config.vue';
  4. 2.配置路径
  5. {
  6. path:'/Course',
  7. name:'Course',
  8. component:Course,
  9. children:[
  10. {
  11. path:'/Course/Info',
  12. name:'Info',
  13. component:Info
  14. },
  15. {
  16. path:'/Course/Config',
  17. name:'Config',
  18. component:Config
  19. }
  20. ]
  21. },
  22. 3.路由配置
  23. <router-link to="/Info"> Info </router-link>
  24. <router-link to="/Config">Config </router-link>
  25. <router-view></router-view>

2、路由守卫

3、组合API

  1. <template>
  2. <div>
  3. <h1>{{name}}</h1>
  4. <button @click="fun">点击增加</button>
  5. <p v-text="data.value"></p>
  6. <p>asjfdh</p>
  7. </div>
  8. </template>
  9. <script>
  10. import { reactive,ref ,watch} from 'vue';
  11. export default{
  12. setup(){
  13. const name='yk';
  14. let data = reactive({
  15. value:0
  16. });
  17. const dd = ref('ass');
  18. function fun()
  19. {
  20. data.value++;
  21. console.log(dd.value);
  22. }
  23. watch(dd,()=>{
  24. console.log(dd.value);
  25. })
  26. return {
  27. name,
  28. fun,
  29. data
  30. }
  31. }
  32. }
  33. </script>
  34. <!-- <script setup>
  35. import { numberLiteralTypeAnnotation } from '@babel/types';
  36. import { reactive } from 'vue';
  37. const name='yk';
  38. let num = 0;
  39. let data = reactive({
  40. value:num
  41. })
  42. let fun = ()=>{
  43. data.value++;
  44. }
  45. </script> -->
  46. <!-- <script>
  47. import { reactive,ref } from 'vue';
  48. export default{
  49. setup(){
  50. const name='yk';
  51. let data = reactive({
  52. value:0
  53. });
  54. const dd = ref('asd');
  55. function fun()
  56. {
  57. data.value++;
  58. console.log(dd.value);
  59. }
  60. return {
  61. name,
  62. fun,
  63. data
  64. }
  65. }
  66. }
  67. </script> -->
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