我在 nodeJs 中遇到路径问题,当他在 url 中指定语言时,我将用户路由到索引页面,如下所示:
app.all('/:locale?/index',function(req,res,next){
if(!req.params.locale){
console.log('no param');
res.render('index');
} else {
var language = req.params.locale;
i18n.setLocale(language);
res.render('index');
}
});
但是,在我的 index.html 页面中,图像的来源是这样指定的: ./images/img1.png ,当我路由用户时,我的 index.html 显示找不到图像,因为它考虑了路径“ lang/images/img1 .png ,它考虑了我网址中的语言,你能帮忙吗?
谢谢