简体   繁体   English

Joomla 添加第 3 方组件

[英]Joomla add 3rd party component

I'm trying to include a svelte app to Joomla site by copy all files from public to Joomla local folder, and in Joomla, I've created an article with a script where I include this index.html我试图通过将所有文件从public复制到 Joomla 本地文件夹来将一个svelte应用程序包含到Joomla站点中,并且在 Joomla 中,我创建了一篇带有脚本的文章,其中包含此index.html

Svelte output苗条的输出

+---public
|   |   favicon.png
|   |   index.html
|   |   output.doc
|   |   
|   \---build
|           bundle.css
|           bundle.css.map
|           bundle.js
|           bundle.js.map

Joomla script to include index.html用于包含 index.html 的 Joomla 脚本

{source}

<?php ini_set("include_path", "/var/www/vhosts/examplesite.com/httpdocs/files/forms/public"); ?>

<?php include 'index.html'; ?>

{/source}

Locally when I launch index.html from the public, all works fine, bun in Joomla noop.在本地,当我从公众发布 index.html 时,一切正常,Joomla noop 中的 bun。 The error is that Joomla can't find files from build folder, for example in index.html are included bundle.css like this:错误是 Joomla 无法从构建文件夹中找到文件,例如在index.html中包含bundle.css,如下所示:

<script defer src='./build/bundle.js'></script>

And I expected what full path for bundle.js will be:我预计bundle.js 的完整路径是:

https://www.examplesite.com/files/forms/public/bundle.js

but actually, the browser requires it from但实际上,浏览器需要它来自

https://www.examplesite.com/bundle.js

So, there is a problem with the path for all files from the build folder.因此,构建文件夹中所有文件的路径存在问题。 Help !!!帮助 !!!

if you do如果你这样做

<script defer src='./build/bundle.js'</script>

the browser will indeed try to get it from the location you mentioned, this is because the ./ part indicates the root and makes it an absolute path.浏览器确实会尝试从您提到的位置获取它,这是因为./部分表示并使其成为绝对路径。

Change your markup to:将您的标记更改为:

<script defer src='/build/bundle.js'</script>

to have it search the bundle files relatively to the current location.让它搜索相对于当前位置的包文件。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM