NodeJS 未找到Adminjs组件加载程序

cunj1qz1  于 2022-12-12  发布在  Node.js
关注(0)|答案(2)|浏览(80)

我一直在尝试在Adminjs 6.6.5 Jmeter 板中制作自定义组件,但Adminjs ComponentLoader未找到错误发生。然后我尝试

import AdminJS from 'adminjs'
const {ComponentLoader} = AdminJS

但我得到:尝试捆绑文件“file:/Users/Josip/WebstormProjects/ferry-backend/components/dashboard.jsx”,但它不存在
我真的很感激你的帮助...

admin/index.js

import {ComponentLoader} from "adminjs";

const componentLoader = new ComponentLoader()

const Components = {
    MyDashboard: componentLoader.override('Dashboard','../components/dashboard.jsx')
}

export { componentLoader, Components }

index.js

import {componentLoader, Components} from "./admin/index.js";
AdminJS.registerAdapter(AdminJSSequelize)
const admin = new AdminJS({
    databases: [],
    rootPath: '/admin',
    resources:[UsersResources, GuestResources, SalesResources, FinancesResources],
    components:{
          edit: Components.MyDashboard
         },
    componentLoader

})
rjee0c15

rjee0c151#

你解决了这个问题吗?我也遇到了这个问题,不知道怎么解决

3zwjbxry

3zwjbxry2#

我修复了这个问题。你需要做的导入如下

import AdminJs from 'adminjs';
// And now you can use any adminjs dependencies as follows
AdminJs.ValidationError(errors)

我的用法示例:

if(Object.keys(errors).length) {throw new AdminJs.ValidationError(errors)} else {...}

祝您的发展顺利!

相关问题