简体   繁体   English

有没有办法从项目目录外部链接外部库?

[英]Is there a way to link an external library from outside the project directory?

I have a jquery library in my project but need to put it in linux /usr/share/js directory and not inside of my project directory. 我的项目中有一个jquery库,但需要将它放在linux / usr / share / js目录中,而不是放在我的项目目录中。

Is there a way to do a linking in the index.html? 有没有办法在index.html中进行链接?

Including in the index.html: 在index.html中包括:

   <script src="/usr/share/js/jquery.min.js"></script>      

doesn't help, as it looks into my working dir and I don't have a 'usr' dir 没有帮助,因为它查看了我的工作目录,而我没有“ usr”目录

/usr/share is in the root directory and not in my working one. / usr / share在根目录中,而不在我的工作目录中。 I don't use any php or the stuff, is there a simple way to solve this? 我不使用任何PHP或其他东西,有没有简单的方法可以解决此问题?

You need to back out of the file you are currently in by using the ../ command which goes back one directory. 您需要使用../命令返回当前目录,该命令返回一个目录。 Depending on how many files deep the index.html file is in your project, you may need more then one like so: 根据项目中index.html文件的深度,可能需要多个文件,如下所示:

<script src="../../../../usr/share/js/jquery.min.js"></script>

This will direct you 4 files out of where your index.html file is located, you may need more or less depending just do some searching through your directories and adjust accordingly. 这会将4个文件引出index.html文件所在的位置,您可能需要或多或少地依赖于只是在目录中进行一些搜索并相应地进行调整。

You can create symlinks for files like this, to allow access to serve from not your document root. 您可以为此类文件创建符号链接,以允许从您的文档根目录而不是文件根目录进行访问。 The web server is also needs to be configured to follow symlinks when serving. 服务时还需要将Web服务器配置为遵循符号链接。

More info for Apache: http://httpd.apache.org/docs/2.4/urlmapping.html 有关Apache的更多信息: http : //httpd.apache.org/docs/2.4/urlmapping.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在我的 PHP 项目根目录之外链接 JS 外部文件? - How do I link JS external files outside of my PHP project root directory? 如何在项目外部安装grunt并从项目目录运行任务 - How to install grunt outside of a project and run tasks from the project directory 从谷歌地图之外的外部链接打开 infoWindows - Open infoWindows from an external link outside of the google map 如何将“ javascript:scrollto(&#39;。class&#39;);”转换为外部链接(从外部指向站点上的某个.class)? - How to transform “javascript:scrollto('.class');” to an external link (leading to a certain .class on the site from the outside)? 从外部连接时如何将外部文件包含到node js项目中 - How to include external files to node js project while connecting from outside React Native:在项目目录之外导入模块 - React Native: Import modules outside of project directory 在实习生中加载项目目录之外的依赖项 - Loading dependencies outside of project directory in the Intern 有没有办法从 React 项目链接到 vanilla JS 项目? - Is there any way to link from a React project to a vanilla JS one? 是否可以在没有相对路径的情况下从项目目录之外要求模块? - Is it possible to require modules from outside of your project directory without relative paths? 从外部目录启动grunt - Launch grunt from outside directory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM