Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👾 BUG | 修复菜单组件文件不存在时页面空白的问题 #25

Closed
auven opened this issue Jun 1, 2020 · 1 comment
Closed

Comments

@auven
Copy link

auven commented Jun 1, 2020

开发过程中,同事创建了新的菜单页面,而我本地没有他新创建的页面文件,导致了页面空白。

let route = {
path: sourceItem.route_path,
name: sourceItem.route_name,
meta: {
title: sourceItem.menu_name,
auth: true,
cache: sourceItem.route_cache === context.env.VUE_APP_DICT_IS_TRUE
},
component: utils.import(sourceItem.route_component)
}
// 为动态注册的路由可以正常在演示环境上显示源码链接而设置,如果不需要显示源码的功能,请移除此属性
// https://github.com/d2-projects/vue-filename-injector 只处理 .vue 类型的文件 所以需要在路由上设置源码路径信息
if (context.env.VUE_APP_SCOURCE_LINK === 'TRUE') {
route.meta.source = 'src/views/' + sourceItem.route_component + (/(.js|.vue)$/.test(sourceItem.route_component) ? '' : '/index.js')
}
routes.push(route)

修复:

        try {
          let route = {
            path: sourceItem.route_path,
            name: sourceItem.route_name,
            meta: {
              title: sourceItem.menu_name,
              auth: true,
              cache: sourceItem.route_cache === context.env.VUE_APP_DICT_IS_TRUE
            },
            component: utils.import(sourceItem.route_component)
          }
          routes.push(route)
          // 为动态注册的路由可以正常在演示环境上显示源码链接而设置,如果不需要显示源码的功能,请移除此属性
          // https://github.com/d2-projects/vue-filename-injector 只处理 .vue 类型的文件 所以需要在路由上设置源码路径信息
          if (context.env.VUE_APP_SCOURCE_LINK === 'TRUE') {
            route.meta.source = 'src/views/' + sourceItem.route_component + (/(.js|.vue)$/.test(sourceItem.route_component) ? '' : '/index.js')
          }
          routes.push(route)
        } catch (err) {
          utils.log.capsule('菜单', '文件不存在', 'danger')
          utils.log.danger(err.message)
        }
@FairyEver
Copy link
Member

FairyEver commented Jun 1, 2020

cf293d3

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants