es6模块化不能及时导出对象的子对象怎么办

发布于 2022-09-12 02:53:57 字数 9139 浏览 20 评论 0

react
我设置的路由配置

import asyncComponent from './asyncComponent'
import { Console } from 'lwp-mini-tools'
const InstallationOfSP = asyncComponent(() => import('../view/InstallationOfSP/index'))
const ComponyMessage = asyncComponent(() => import('../view/InstallationOfSP/ComponyMessage'))
const EmptyRoute = asyncComponent(() => import('./EmptyRoute'))
const ProductManager = asyncComponent(() => import('../view/productManager/index.jsx'))
const ProductList = asyncComponent(() => import('../view/productManager/ProductList.jsx'))
const OrderList =asyncComponent(()=>import('../view/productManager/OrderList'))
const OrderAnalyze=asyncComponent(()=>import('../view/productManager/OrderAnalyze'))
const ProductPublish = asyncComponent(() => import('../view/productManager/ProductPublish.jsx'))
const ProductAnalyze =asyncComponent(()=>import('../view/productManager/ProductAnalyze.jsx'))
const ProductHistory = asyncComponent(() => import('../view/productManager/ProductHistory.jsx'))
const ClassifyManager = asyncComponent(() => import('../view/productManager/ClassifyManager.jsx'))
const ProductBlackList = asyncComponent(()=>import('../view/productManager/ProductBlackList'))
const ProviderAuthentication = asyncComponent(() => import('../view/ProviderAuthentication'))
//商品咨询
const AskList = asyncComponent(() => import('../view/ProductAsk/AskList'))
//店铺管理
const ProviderManager = asyncComponent(() => import('../view/ProviderManager/ProviderManager'))
//ProductAudit
const ProductAudit = asyncComponent(() => import('../view/productManager/ProductAudit'))
//需求管理
const NeedsSquare = asyncComponent(() => import('../view/needsManager/NeedsSquare'))
const myBidding = asyncComponent(() => import('../view/needsManager/myBidding'))
//系统管理
const OfficialManager = asyncComponent(() => import('../view/systemManager/OfficialManager'))
const ShufflingManager = asyncComponent(() => import('../view/systemManager/ShufflingManager'))
const ShufflingManagerForm =asyncComponent(()=>import('../view/systemManager/ShufflingManagerForm'))
const route = [
    {
        path: '/installationOfSP',
        id:'installationOfSP',
        name: '服务商入驻',
        icon: 'user',
        role: ['0'],
        component: InstallationOfSP,
        children: [
            {
                path: '/installationOfSP/connectMessage',
                id:'installationOfSP-connectMessage',
                name: '服务商入驻',
                role: ['0'],
                component: EmptyRoute,
            },
        ]

    },
    {
        path: '/productManager',
        id:'productManager',
        name: '商品管理',
        icon: 'laptop',
        component: ProductManager,
        role: ['1','2'],
        children: [
            {
                path: "/productManager/productList",
                name: '商品列表',
                id:'productManager-productList',
                role:['1'],
                component: ProductList,
            },
            {
                path: "/productManager/productPublish",
                name: '商品发布',
                id:'productManager-productPublish',

                hide:true,
                role:['1'],

                component: ProductPublish,
            },
            {
                path: "/productManager/productAnalyze",
                name: '商品分析',
                id:'productManager-productAnalyze',
                hide:true,
                role:['1'],
                component: ProductAnalyze,
            },
            {
                path: "/productManager/productHistory",
                id:'productManager-productHistory',

                name: '历史商品',
                role:['1'],

                component: ProductHistory,
            },
            {
                path: "/productManager/orderList",
                name: '订单',
                id:'productManager-orderList',
                role:['1'],
                component: OrderList,
            },
            // {
            //     path: "/productManager/orderAnalyze",
            //     name: '订单分析',
            //     id:'productManager-orderAnalyze',
            //     role:['1'],
            //     component: OrderAnalyze,
            // },
            {
                path: "/productManager/productAudit",
                id:'productManager-productAudit',

                name: '商品质量审核',
                role:['2'],
                component: ProductAudit,
            },
            {
                path: "/productManager/classifyManager",
                id:'productManager-classifyManager',

                name: '商品分类管理',
                role:['2'],
                component: ClassifyManager,
            },
            {
                path: "/productManager/productBlackList",
                id:'productManager-productBlackList',

                name: '商品关键词黑名单',
                role:['2'],
                component: ProductBlackList,
            },
            
        ]
    },
    {
        path: '/productAsk',
        id:'productAsk',
        name: '商品咨询',
        icon: 'laptop',
        component: EmptyRoute,
        role: ['1'],
        children: [
            {
                path: "/productAsk/askList",
                id:'productAsk-askList',
                name: '咨询列表',
                role: ['1'],
                component: AskList,
            },
        ]
    },
    {
        path: '/providerManager',
        id:'providerManager',
        name: '店铺管理',
        icon: 'laptop',
        component: EmptyRoute,
        role: ['1'],
        children: [
            {
                path: "/providerManager/providerManager",
                id:'providerManager-providerManager',
                name: '店铺管理',
                role: ['1'],
                component: ProviderManager,
            },
        ]
    },
    {
        path: '/provider/authentication',
        id:'provider-authentication',
        name: '企业认证',
        icon: 'laptop',
        component: EmptyRoute,
        role: ['2'],

        children: [
            {
                path: "/provider/authentication/list",
                id:'provider-authentication-list',
                name: '申请列表',
                component: ProviderAuthentication,
                role: ['2'],
            },
        ]
    },
    {
        path: '/needs/manager',
        id:'needs-manager',
        name: '需求管理',
        icon: 'laptop',
        component: EmptyRoute,
        role: ['1'],
        children: [
            {
                path: "/needs/square",
                id:'needs-square',
                name: '需求广场',
                component: NeedsSquare,
                role: ['1'],
            },{
                path: "/needs/myBidding",
                id:'needs-myBidding',
                name: '我的竞标',
                component: myBidding,
                role: ['1'],
            },
        ]
    },
    {
        path:'system/manager',
        id:'system-manager',
        name: '系统管理',
        icon: 'laptop',
        component: EmptyRoute,
        role: ['2'],
        children: [
            {
                path: "/official/manager",
                id:'official-manager',
                name: '官方信息管理',
                component: OfficialManager,
                role: ['2'],
            },
            {
                path: "/shuffling/manager",
                id:'shuffling-manager',
                name: '轮播图管理',
                component: ShufflingManager,
                role: ['2'],
            },
            {
                path: "/shuffling/managerform",
                id:'shuffling-manager-form',
                name: '轮播图管理详情页',
                component: ShufflingManagerForm,
                role: ['2'],
                hide:true
            }
        ]
    }
]
export default route

过滤方法

import route from './menuconfig'
function filterMenu(role) {
    console.log('route')
    console.log(route)
    return route.filter(item => {
        if(item.children) item.children=item.children.filter(i=>{
            switch (role) {
                case '0':
                    if (i.path === '/installationOfSP') {
                        return true
                    } else {
                        return false
                    }
                    break;
                case '1':
                    return i.role.indexOf('1') !== -1
                    break;
                case '2':
                    return i.role.indexOf('2') !== -1
                    break;
            }
        })
        switch (role) {
            case '0':
                if (item.path === '/installationOfSP') {
                    return true
                } else {
                    return false
                }
                break;
            case '1':
                return item.role.indexOf('1') !== -1
                break;
            case '2':
                return item.role.indexOf('2') !== -1
                break;
        }

    })
}
export default filterMenu
// route =

加载进来的children一开始是空的,得重新刷新一下才能有值,怎么破

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2022-09-19 02:53:57

跟模块化没关系,children出不来,用深拷贝一下route就出来了

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文