【问题标题】:Joomla add 3rd party componentJoomla 添加 3rd 方组件
【发布时间】:2021-01-11 17:28:15
【问题描述】:

我正在尝试通过将所有文件从 public 复制到 Joomla 本地文件夹和 Joomla 中来将 svelte 应用程序包含到 Joomla 网站,我创建了一篇包含此 index.html

的脚本的文章

苗条输出

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

包含 index.html 的 Joomla 脚本

{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 文件夹中找到文件,例如在 index.html 中包含 bundle.css 如下:

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

我预计 bundle.js 的完整路径会是:

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

但实际上,浏览器需要它来自

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

因此,build 文件夹中所有文件的路径都存在问题。救命!!!

【问题讨论】:

  • 如果您正在做 Joomla 开发,那么您应该在Joomla Stack Exchange 上注册一个帐户。每当您有与 Joomla 相关的问题或将受益于对 Joomla 及其扩展有深入了解的志愿者的支持时,请在 JSE 上提问。我们没有得到足够的问题area51.stackexchange.com/proposals/58842/joomla

标签: javascript php html joomla svelte


【解决方案1】:

如果你这样做

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

浏览器确实会尝试从您提到的位置获取它,这是因为./ 部分表示并使其成为绝对路径。

将您的标记更改为:

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

让它搜索相对于当前位置的捆绑文件。

【讨论】:

  • 我收到一个错误:拒绝应用来自 'examplesite.com/en/build/bundle.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-06
  • 1970-01-01
  • 1970-01-01
  • 2015-09-15
  • 1970-01-01
相关资源
最近更新 更多