Vue的路由配置

拜拜、爱过 提交于 2019-11-27 05:59:41

设置路由界面router.js
import 和 设置 routes

import Vue from 'vue'
import vuerouter from 'vue-router'
import firstpage from '../components/routerpage/index'
import active from '../components/routerpage/active.vue'
let router=new vuerouter({
    mode:"history",
    routes:[
        //配置路由
        {
            path:"/",
            name:"firstpage",
            component:firstpage
        },{
            path:"/active",
            name:"active",
            component:active
        }
    ]
});
Vue.use(vuerouter);
export default router;

对应action

{
          title: "电影",
          img: "../../../public/img/ymiao.png",
          activeimg: "../../../public/img/miao.png",
          action: "/",
          useractive: true
        },
        {
          title: "活动",
          img: "../../../public/img/yshu.png",
          activeimg: "../../../public/img/shu.png",
          action: "/active",
          useractive: false
        },

设置routerlink

  <router-link :to="item.action">
          <img class="img" :src="`public/img/${item.useractive?item.img:item.activeimg}`" alt="">
          <br>
          {{item.title}}</router-link>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!