根据 HTML 中的特定目录设置路径?

Set path based on specific directory in HTML?

假设我在

main/component1/index.html

我希望我的 html 按钮 link 我 main/component2/

但是同样的index.html文件也用于目录

main/component3/dir1/index.html

我仍然想 link 到 main/component2/

规格:

我该怎么做?谢谢!

如果我理解你的问题 - 不,你不能只用 HTML,因为 HTML 不是编程语言,而是标记语言。

您可以创建相对路径和绝对路径,但不能创建“可变”路径。

在此处阅读更多内容: