如何在Magento2中使用自定义模块为所有页面添加CSS和JS?

时间:2016-08-29 14:39:06

标签: php magento magento2

我正在尝试使用Magento 2中的自定义模块Magento_Test为所有网站页面添加自定义CSS和JS文件。我使用布局文件在前端添加了CSS和JS文件。

Magento/Test/view/frontend/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="Magento_Test/css/style.css"/>
        <link src="Magento_Test/js/script.js"/>
    </head>
</page>

CSS和JS文件仅包含在自定义模块页面中。那么,如何使用自定义模块为所有模板/网站页面在Magento2中添加CSS和JS?

1 个答案:

答案 0 :(得分:-1)

根据docs您想要使用的import pandas as pd test = pd.DataFrame({'Address 1': ["'aaa",'sa,ss"']}) print (test) Address 1 0 'aaa 1 sa,ss" test['Address 1'] = test['Address 1'].str.replace(r"[\"\',]", '') print (test) Address 1 0 aaa 1 sass 代替default_head_blocks.xml

如果您正在使用模块并且已创建这些文件,这对我有用 - default.xml Namespace/Module/view/frontend/view/frontend/web/my-styles.css

现在在

Namespace/Module/view/frontend/view/frontend/web/hello.js

Namespace/Module/view/frontend/view/layout/default_head_blocks.xml