zoukankan      html  css  js  c++  java
  • Vue学习手记03-路由跳转与路由嵌套


    1.路由跳转

    1.   添加一个LearnVue.vue文件,
    2.   在router->index.js中 引入import Learn from '@/components/LearnVue'
    3.   在touter中添加路由说明
     export default new VR({
        routes:[
          {
            path:"/hello",
            name:"HelloWorld",
            component:HelloWorld
          },
             {
            path:"/learn",
            name:"Learn",
            component:Learn
          }      
        ]
      })
    

        4.在需要切换的地方使用标签router-link

        <ul>
          <router-link tag="li" to="hello"> hello</router-link>
          <router-link to="learn"> learn</router-link>
        </ul>

      属性:

    • to="hello"指定跳转的路由页面
    • tag 可以用于指定router-link标签的渲染标签,tag="li"就是安装li的标签样式来渲染。


    2.动态路由(参数传递)
      /:id  多个参数就 /:id/:name

    3.路由嵌套
    01.引入子路由后
    02.在创建路由时,添加一个children ,多级嵌套就添加多个children

    export default new VR({
          routes:[
          {
            path:"/hello",
            name:"HelloWorld",
            component:HelloWorld
          },
             {
            path:"/learn",
            name:"Learn",
            component:Learn,
        children:[
          {
            path:"base",
            component:Base    
          }
        ]
          }      
        ]
      })


    03跳转的地方:to="/Learn/Base"这个要写全,不能只写Base

    <router-link tag="li" to="/Learn/Base"> Base </router-link>

     

  • 相关阅读:
    动态投影
    我的比较差的初级的研究成果
    我最近的研究成果(IGeometry.Project and IGeometry.SpatialReference)
    mysql中的数据类型以及常见约束
    面向对象——多态
    java基础
    java中的异常(3)
    mysql中的数据类型
    面向对象——继承
    java中的异常(2)
  • 原文地址:https://www.cnblogs.com/somethingWithiOS/p/11185062.html
Copyright © 2011-2022 走看看