我一直试图为Adminjs仪表板制作我的自定义组件。我的项目是用Nodejs制作的,Adminjs可以在React中进行自定义,所以我在组件/仪表板文件夹中创建了dashboard.jsx文件,但是当我在Adminjs.bundle中实现该文件时,我会得到一个文件“./components/仪表板/仪表板”。它只是不想找到通向我的组件的路径。请帮帮忙!
我用ComponentLoader:Adminjs ComponentLoader not found打开了一个新的问题
import React, {useEffect, useState} from 'react'
import {ApiClient} from "adminjs";
const api = new ApiClient();
const Dashboard = () => {
const [data, setData] = useState({})
useEffect(() => {
api.getDashboard().then((response) => {
setData(response.data)
})
}, [])
return(
<div>
<h1>it works!</h1>
</div>
)
};
export default Dashboardindex.js:
AdminJS.registerAdapter(AdminJSSequelize)
const admin = new AdminJS({
databases: [],
rootPath: '/admin',
dashboard:{
component: AdminJS.bundle("./components/dashboard/dashboard"),
},
resources:[UsersResources, GuestResources, SalesResources, FinancesResources]
})

发布于 2022-11-06 12:33:40
尝试将./components/dashboard/dashboard替换为./components/dashboard/dashboard.jsx。
我只经历了一点点,所以我不确定这是否是问题所在。
发布于 2022-11-26 12:01:59
这种情况的解决办法是:
AdminJS.registerAdapter(AdminJSSequelize)
const admin = new AdminJS({
databases: [],
rootPath: '/admin',
dashboard:{
component: AdminJS.bundle(path.join(process.cwd(),"./components/dashboard/dashboard")),
},
resources:[UsersResources, GuestResources, SalesResources, FinancesResources]
})然而,一个新版本的Adminjs出现了,.bundle被贬低了,您应该使用ComponentLoader,这对我来说是行不通的。请在这里检查我的问题:Adminjs ComponentLoader not found
https://stackoverflow.com/questions/74329803
复制相似问题