zoukankan      html  css  js  c++  java
  • vue 路由工程化重构

    当项目越来越庞大的时候,路由越来越多,而且遍布的页面也越来越多,

    当需要更换地址的时候就无比的繁琐,通过学习了解到可以通过router.js来统一调控

    原理: 在路由页面通过name来进行跳转,传入的是{name:'...'}

    这样需要修改页面路径的时候只需要在router.js里面修改路径就可以了

    router/index.js

    export default new Router({
    mode: 'history',
    base: _dirname,
    linkActiveClass: "active", routes: [ { path:
    '/', name: 'First', component: first }, { path: '/agedserve', name: 'Agedserve', component: agedserve }, { path: '/carserve', name: 'Carserve', component: carserve }, { path: '/safeguard', name: 'Safeguard', component: safeguard }, { path: '/verbpage', name: 'Verbpage', component: verbpage } ] })

    路由页面

    <router-link tag="li" :to="{name:'Verbpage', params: {}}">
        <img src="../../static/images/insurance-icon.png" alt="icon">
        <div class="project-child">
           <h3>风险评测</h3>
           <p></p>
        </div>
    </router-link>
  • 相关阅读:
    C++第三章习题
    C++第五章习题
    C++第八章习题
    C++第四章习题
    第八章 图形编程 笔记
    第五章 Windows程序设计 笔记
    [转]c++ 结构体和类的区别
    C++第二章习题
    C++第六章习题
    Ubuntu10.04中设置和修改root密码
  • 原文地址:https://www.cnblogs.com/ralapgao/p/9883169.html
Copyright © 2011-2022 走看看