【问题标题】:How to override html file in magento 2.1如何在 magento 2.1 中覆盖 html 文件
【发布时间】:2016-09-27 09:40:00
【问题描述】:

我需要自定义 Magento_Checkout 模块。

我试图将该 html 文件复制到我的主题路径中,但覆盖不起作用

覆盖下面提到的路径

/app/design/frontend/Vendor/ThemeName/Magento_Checkout/web/template

但文件取自

/vendor/magento/module-checkout/view/frontend/web/template

如何覆盖这个模板 html 文件?

【问题讨论】:

    标签: magento2


    【解决方案1】:

    如果发生这样的事情,你可以做什么:

    var config = {
        map: {
            '*': {
                'Magento_Checkout/template/shipping.html': 'MyNameSpace_MyModule/template/shipping.html'
    
            },
        }
    };
    

    基本上你必须创建自己的 Vendor 模块,并在 requirejs-config.js 中声明它到 MyNameSpace/MyModule/view/frontend/requirejs-config.js

    希望对你有帮助!

    【讨论】:

      【解决方案2】:

      假设你想覆盖文件:

      vendor/magento/module-checkout/view/frontend/web/template/shipping.html
      

      为此,您需要将替换文件放在:

      app/design/frontend/{Vendor}/{Theme}/Magento_Checkout/web/template/shipping.html
      

      如果您在页面刷新后没有看到更改,请尝试刷新 JavaScript/CSS 缓存静态文件缓存

      【讨论】:

      • 我尝试了同样的方法,并在外部 li 中添加了一个额外的类名,它没有从覆盖代码中获取它仍然从供应商核心结帐代码中获取,我使用的是 magento 2.2,请告诉我如何解决.
      • 如果你使用 n98-magerun,你可以运行n98-magerun2 dev:asset:clear(你应该这样做!)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多