【发布时间】:2022-01-14 06:10:37
【问题描述】:
我有一个 SideNav 菜单,用于查找名为 route.js 的文件,其中包含一个名为 routes 的数组。我正在尝试从另一个组件更改 routes.js 中路由的值。我希望能够从组件中添加删除文件 routes.js 中的物理数组。任何帮助将不胜感激。
import Shop from "examples/Icons/Shop";
// import Office from "examples/Icons/Office";
const routes = [
{
type: "collapse",
name: "Our Mission",
key: "dashboards",
icon: <Shop size="12px" />,
collapse: [
{
name: "Ways We can Help",
key: "default",
route: "/dashboards/default",
component: Default,
},
{
name: "How It Works",
key: "automotive",
route: "/dashboards/automotive",
component: Automotive,
},
{
name: "Who We Are",
key: "smart-home",
route: "/dashboards/smart-home",
component: SmartHome,
},
],
},
{ type: "title", title: " ", key: "space1" },
{
type: "collapse",
name: "Services",
key: "services",
icon: <Shop size="12px" />,
href: "https://github.com/creativetimofficial/ct-soft-ui-dashboard-pro-material-ui/blob/main/CHANGELOG.md",
component: Default,
noCollapse: true,
},
];
export default routes;
组件访问 routes.js
import routes from "../../../routes";
const loggedroutes = [
{
type: "collapse",
name: "Profile",
key: "profile",
icon: <CgProfile size="12px" color="blue" />,
route: "/dashboards/Default",
collapse: [],
},
{
type: "collapse",
name: "Calendar",
key: "calendar",
component: link,
route: "/dashboards/Default",
icon: <GoCalendar size="12px" color="blue" />,
collapse: [],
},
]
routes = loggedinroutes;
我想更改 routes.js 中的数据以匹配数组 loggedinroutes
【问题讨论】:
-
什么是“物理阵列”?
-
您是说要写入文件吗?这与更新内存中的数组不同。
-
我要写入文件
标签: node.js arrays reactjs jsx