我正在尝试为其中包含“ / car /”的所有路径加载搜索组件。
在我的index.js中,我有:
public static async Task SaveExp(ulong guildId, ulong userId, int level, uint xp, DateTime cooldown)
{
using (var dbContext = new DatabaseHandler())
{
if (dbContext.Exps.Any(x => x.GuildId == guildId && x.UserId == userId))
{
var current = dbContext.Exps.FirstOrDefault(x => x.GuildId == guildId && x.UserId == userId);
if (current != null)
{
current.Xp += xp;
current.Level += level;
dbContext.Exps.Update(current);
}
}
else
{
dbContext.Exps.Add(new Exp
{
GuildId = guildId,
UserId = userId,
Level = level,
Xp = xp,
Cooldown = cooldown
});
}
await dbContext.SaveChangesAsync();
}
}
当我导航到/ car / hello时,我希望它会加载Search组件,因为我指定了/ car /路径,但这不起作用。
我也尝试使用/ car / *,但这仍然行不通。
有人知道我在做什么错吗?在过去的几个小时中,我一直在挠头。
答案 0 :(得分:0)
默认情况下,其余路径中都包含/
路径,因此您必须使用exact
将其与其余路径区分开。
var indexRoutes = [
{ path: "/", name: "Dashboard", component: Fulllayout, exact: true },
{ path: "/authentication", name: "Athentication", component: Blanklayout, exact: false }
];
...
indexRoutes.map((prop, key) => {
return (
<Route
path={prop.path}
key={key}
component={prop.component}
exact={prop.exact}
/>
);
});