美文网首页
vue 第八章

vue 第八章

作者: 天色见晚 | 来源:发表于2018-09-27 10:36 被阅读0次

    路由
    1.路由下载用git
    npm install vue
    npm install vue-router

    2.路由嵌套
    嵌套路由就是路由里面嵌套他的子路由
    子路由关键属性children
    每一个子路由里面可以嵌套多个组件
    子组件又有路由导航和路由容器

    3.路由传参
    使用 <router-link :to="{name:'edithospital',params:{hid:101}}">编辑</router-link>

    1.在路由配置中添加

    {
    name:'edithospital', \路由的名字
    path: '/edithospital/:hid', \路由中添加要传递的参数:hid
    component: resolve => require(['../components/page/hospital/EditHospital.vue'], resolve)
    }

    1. A页面

      <router-link :to="{name:'edithospital',params:{hid:101}}">编辑</router-link> \101是变量,可根据实际情况改变

      \name是路由的名字,params是传递的参数

    2. B页面 <template><template>中添加

      {{$route.params.hid}} // 101

    4.vue中使用axios
    1.安装axios
    npm:$ npm install axios

    相关文章

      网友评论

          本文标题:vue 第八章

          本文链接:https://www.haomeiwen.com/subject/czosoftx.html