我是马根托的新手。
我从下面提到的教程中创建了一个模块-2模块。
http://inchoo.net/magento-2/how-to-create-a-basic-module-in-magento-2/有了这个模块,我就把脚本注入到页面中。但有了这个,我只能在模块页面上执行,
http://localhost/magento2/helloworld我已经安装了一个样例存储,但是如果我希望在任何产品页面上执行我的模块,我应该怎么做。
请帮我理解一下。指着一篇文章将不胜感激。
谢谢。
发布于 2017-07-12 05:48:27
在布局xml中的标记中调用css和js文件。示例:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<link src="Namespace_YourModule::script.js"/>
<css src="Namespace_YourModule::style.css"/>
</head>
<body>
</body>
</page>发布于 2016-10-19 08:18:53
我找到了一篇解决这个具体问题的文章。
在这种情况下,他添加了默认的脚本文件,而不是路由。
编辑:在另一篇文章中给出了脚本和css文件的条件加载信息。
http://www.webspeaks.in/2016/03/how-to-add-css-and-js-in-magento-2-custom-module.html
https://stackoverflow.com/questions/40124581
复制相似问题