• 使用element-ui导航,进入对应的三级页面菜单保持点击状态


    1.注意事项

    01.路由中使用了keepAlive属性,要用keepAlive:true,不能等于false,使用false页面会刷新

    2.使用的方法

    3.项目实例

    1. <script>
    2. export default {
    3. data() {
    4. return {
    5. activeIndex: '/policyjisuan',
    6. };
    7. },
    8. watch: {
    9. // 监听路由变化
    10. '$route.path': {
    11. handler (routePath) {
    12. this.initMenuActive(routePath)
    13. },
    14. immediate: true
    15. }
    16. },
    17. methods: {
    18. initMenuActive (routePath) {
    19. //路由跳转时,标记在导航的哪个选项下对应的路由,css高亮显示
    20. if (routePath == '/loginPolicy') {
    21. this.activeIndex = '/policyjisuan'
    22. } else if(routePath == '/searchDetail'){
    23. this.activeIndex = '/searchP'
    24. } else if(routePath == '/applyDetail'){
    25. this.activeIndex = '/applyNews'
    26. } else if(routePath == '/calculateDetail'){
    27. this.activeIndex = '/policyjisuan'
    28. } else if(routePath == '/companyDetail'){
    29. this.activeIndex = '/policyjisuan'
    30. } else if(routePath == '/originalDetail'){
    31. this.activeIndex = '/original'
    32. } else {
    33. this.activeIndex = routePath
    34. }
    35. },
    36. }
    37. }
    38. script>
    39. <style lang="scss" scoped>
    40. /* 导航下页面 */
    41. .navContent {
    42. min-height: 800px;
    43. padding-bottom: 70px;
    44. background-color: #fff;
    45. }
    46. .policyNav {
    47. .el-menu-item {
    48. text-align: center;
    49. border-bottom: none;
    50. width: 16%;
    51. font-size: 22px;
    52. font-weight: 500;
    53. background-color: #486DC0 !important;
    54. }
    55. .el-menu {
    56. background-color: #486DC0 !important;
    57. }
    58. }
    59. style>

    路由配置

    1. js文件
    2. export default [
    3. {
    4. path: '/policyStoreIndex',
    5. name: '政策计算器导航页',
    6. redirect: '/policyjisuan',
    7. component: () =>
    8. import(/* webpackChunkName: "page" */ '@/views/home/policyStoreIndex'),
    9. meta: {
    10. keepAlive: true,
    11. isTab: false,
    12. isAuth: false
    13. },
    14. children: [
    15. {
    16. path: '/searchP',
    17. name: '检索',
    18. component: () =>
    19. import(/* webpackChunkName: "page" */ '@/views/home/policyStoreNew/searchP'),
    20. meta: {
    21. keepAlive: true,
    22. isTab: false,
    23. isAuth: false
    24. }
    25. }]
    26. }
    27. ]

  • 相关阅读:
    面试题:说说Java线程的状态及转换
    GoldenEye
    如果用nodejs开发一个网站
    浅述数据中心供配电系统解决方案及产品选型
    云原生2.0时代,如何让应用拥抱云原生?
    9.变换之平移
    PCL 点云投影到圆柱(C++详细过程版)
    SpringBoot--中间件技术-2:整合redis,redis实战小案例,springboot cache,cache简化redis的实现,含代码
    Rasa 3.x 机器学习构建笔记
    Vue中的.sync修饰符
  • 原文地址:https://blog.csdn.net/weixin_60196946/article/details/132668272