在 HTML 中引用父目录 [英] Referencing a parent directory in HTML

查看:34
本文介绍了在 HTML 中引用父目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就目录的引用而言,我理解

./= 当前../= 父母

但是我在这段 HTML 代码中引用我的 bower_components 目录时遇到问题.对 lib 文件夹的引用工作正常,但不是 bower_components.我错过了什么?

main.html

<头><身体><script src=lib/jquery/dist/jquery.min.js"></script><script src=../bower_components/bootstrap/dist/js/bootstrap.min.js"></script></html>

目录结构如下:

解决方案

尝试转到 /bower_components/bootstrap/dist/js/bootstrap.min.js

这可能行不通.如果您的服务器设置正常,则只有 public 和它下面的文件夹可以从客户端访问.从客户端的角度来看,public 是根,除此之外什么都没有.

至于导入引导程序,请查看您是否可以浏览浏览器中可用的节点.它可能在客户端的另一个 url 上托管您需要引用的脚本.您还可以在 bower 文档/示例中找到该 url.

可以通过将脚本复制或符号链接到公共目录中来解决这个问题,但这有点hackish,如果您完全厌倦了找到预期的方式,请保存它.>

As far as references to directories are concerned, I understand

./ = current
../ = parent

But I am having a problem referencing my bower_components directory in this bit of HTML code. The reference to the lib folder works fine but not bower_components. What am I missing?

main.html

<!DOCTYPE html>
<html>
    <head>
    </head>
    <body>
        <script src="lib/jquery/dist/jquery.min.js"></script>
        <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    </body>
</html>

Directory structure looks like this:

解决方案

Try going to <your server>/bower_components/bootstrap/dist/js/bootstrap.min.js

It probably won't work. If your server setup is normal only public and the folders below it are accessible from the client side. From the client point of view public is the root, there is nothing above that.

As for importing bootstrap, see if you can browse what node is making available in your browser. It's probably hosting the scripts you need to reference on the client side at another url. You might also find the url in the bower documentation/examples.

You could solve this by copying or symlinking the scripts into the public directory, but that would be a bit hackish, save it for if you get completly fed up with finding the intended way.

这篇关于在 HTML 中引用父目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆