问题描述
我正试图通过将所有文件从 public 复制到Joomla本地文件夹以及Joomla中,以在 Joomla 网站中包括一个 svelte 应用程序,我用脚本创建了一篇文章,其中包含了 index.html
苗条的输出
+---public
| | favicon.png
| | index.html
| | output.doc
| |
| \---build
| bundle.css
| bundle.css.map
| bundle.js
| bundle.js.map
Joomla脚本以包含index.html
{source}
<?PHP ini_set("include_path","/var/www/vhosts/examplesite.com/httpdocs/files/forms/public"); ?>
<?PHP include 'index.html'; ?>
{/source}
在本地从公众启动index.html时,一切正常,在Joomla noop中运行。 错误是Joomla无法从 build 文件夹中找到文件,例如,在 bundle.css 中包含了 index.html ,如下所示:
<script defer src='./build/bundle.js'></script>
我希望 bundle.js 的完整路径是:
https://www.examplesite.com/files/forms/public/bundle.js
但是实际上,浏览器需要它
https://www.examplesite.com/bundle.js
解决方法
如果愿意
<script defer src='./build/bundle.js'</script>
浏览器确实会尝试从您提到的位置获取它,这是因为./
部分指示 root 并使其成为绝对路径。
将标记更改为:
<script defer src='/build/bundle.js'</script>
让它相对于当前位置搜索捆绑文件。