javascript page.xml 中的 Magento skin_js 路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13442555/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 18:47:43  来源:igfitidea点击:

Magento skin_js path in page.xml

javascriptxmlmagentopath

提问by jeanluc legros

I tried to add a javascript with a custom template through its page.xml like this:

我试图通过它的 page.xml 添加一个带有自定义模板的 javascript,如下所示:

<action method="addItem"><type>skin_js</type><name>myjs.js#notify</name></action>

Notify will throw an alert windows so I can check if it's correct after reload. In addition I check the source code to see where it tries to go. Template is correctly setup and cache is flushed.

Notify 会抛出一个警告窗口,所以我可以在重新加载后检查它是否正确。此外,我检查源代码以查看它尝试去哪里。模板已正确设置,缓存已刷新。

With the above script it goes to:

使用上面的脚本,它转到:

<script type="text/javascript" src="http://127.0.0.1/magento/skin/frontend/base/default/myjs.js#notify"></script>

Which doesn't exist here.

这里不存在的。

Script is located in skin/frontend/default/blank2/js/live.js

脚本位于 skin/frontend/default/blank2/js/live.js

回答by Renon Stewart

Try changing (assuming that myjs.js is in skin/frontend/default/blank2/js/myjs.js)

尝试更改(假设 myjs.js 在 skin/frontend/default/blank2/js/myjs.js 中)

<action method="addItem"><type>skin_js</type><name>myjs.js#notify</name></action>

to

<action method="addItem"><type>skin_js</type><name>js/myjs.js#notify</name></action>

Because myjs.js is not found in your theme then it will try to look for it in the base theme folder

因为在您的主题中找不到 myjs.js,所以它会尝试在基本主题文件夹中查找它

回答by S P

It means that it cannot find the js in your theme nor the default folder.

这意味着它无法在您的主题或默认文件夹中找到 js。

Change to:

改成:

    <action method="addItem"><type>skin_js</type><name>js/myjs.js#notify</name></action>

回答by Jilani J

If the file doesn't exist into your custom theme path then skin_jswill return the base theme folder path. So make sure your file exist into your custom path and give the correct path.

如果该文件不存在于您的自定义主题路径中,则skin_js将返回基本主题文件夹路径。因此,请确保您的文件存在于您的自定义路径中并提供正确的路径。