zoukankan      html  css  js  c++  java
  • Vue路由机制

    视图层:

    主要是<router-link>和<router-view>两个标签

    <router-link>执行时会转换成<a>,并根据自己的to属性将路由地址转变成href的值,然后渲染在<router-view>标签中。

    js配置路由的两种写法

    写法一:

    index.js

    Vue.use(Router)
    
    export default new Router({
      routes: [
        {path:'/',component:Home},
        {path:'/detail',component:detail}
      ]
    })

    main.js

    import router from './router/index.js'
    
    new Vue({
      router,
      render: h => h(App)
    }).$mount('#app-box')

    写法二:

    main.js

    import Home from 'xxx'
    import detail from 'xxx'
    
    Vue.use(VueRouter)
    
    const routes = [{  //定义路由表
      path: '/',
      component: Home
    },{
      path: '/detail',
      component: detail
    }]
    
    const router = new VueRouter({创建router管理上面定义好的routes
      routes
    })
    
    new Vue({    //将配置好的router注入Vue根实例中
      router,
      render: h => h(App)
    }).$mount('#app-box')
  • 相关阅读:
    pygame--颜色变化
    pyQt绘图
    pyqt布局管理器
    java执行shell/cmd命令
    word公式编辑器公式
    pygame绘制文本
    2.add two number
    eltwise层
    crop层
    fcn
  • 原文地址:https://www.cnblogs.com/dengxiaobo/p/7826110.html
Copyright © 2011-2022 走看看