Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/153.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
节点/express锚链接不指向其他HTML静态页面_Html_Node.js_Express - Fatal编程技术网

节点/express锚链接不指向其他HTML静态页面

节点/express锚链接不指向其他HTML静态页面,html,node.js,express,Html,Node.js,Express,我正在构建我的第一个node.js/express.js项目。这就是我儿子的长相 在我的index.html和favorites.html文件中,我包含了锚定标记,用于在两个页面之间导航: 请使用以下路线: const express=require('express'); 常量app=express(); 应用程序使用(express.static('public')); app.get('/',函数(请求,响应){ sendFile(uu dirname+'./public/index.h

我正在构建我的第一个node.js/express.js项目。这就是我儿子的长相

在我的
index.html
favorites.html
文件中,我包含了锚定标记,用于在两个页面之间导航:


请使用以下路线:

const express=require('express');
常量app=express();
应用程序使用(express.static('public'));
app.get('/',函数(请求,响应){
sendFile(uu dirname+'./public/index.html');
});
app.get(“/favorites”),函数(请求、响应){
sendFile(uu dirname+'./public/favorites.html');
});


如果单击链接不起作用,但直接转到URL却起作用,那么问题与Express无关,与客户端代码有关。在其他条件相同的情况下,问题是没有什么可点击的(可能您有一些CSS试图提供一些背景图像供点击,但您没有在问题中演示问题(提供一个!)而且这种方法存在严重的可访问性问题。如果您想让图像单击,请使用带有
alt
属性的
!静态
模块有什么问题吗?为什么他们必须为每个静态页面创建显式路由?您能共享完整的index.html文件吗?我之前也尝试过这个解决方案,但运气不佳但我刚刚添加了显式路由以重试,index.html上的导航链接似乎仍然无法将我重定向到favorites.html。作为对@Quentin的回应,也感谢您的建议。我将html图标替换为使用alt的图像,并注释掉css文件,以查看这是否是链接到我的css文件的问题但奇怪的是,锚点标记似乎仍然无法正常工作,index.html文件是